Interface

SharedTransitionScope.SharedContentConfig

SharedContentConfig allows a shared element to be disabled or enabled dynamically through isEnabled property.

Common
public interface SharedContentConfig

SharedContentConfig allows a shared element to be disabled or enabled dynamically through isEnabled property. By default, shouldKeepEnabledForOngoingAnimation is true. This means if the shared element transition is already running for the layout that this SharedContentConfig is applied to, we will keep the shared element enabled until the animation is finished. In other words, disabling shared element while the animation is in-flight will have no effect, unless shouldKeepEnabledForOngoingAnimation is overridden.

alternativeTargetBoundsInTransitionScopeAfterRemoval defines an alternative target bounds for when the target shared element is disposed amid animation (e.g., scrolled out of the viewport and subsequently disposed). By default, no alternative target bounds is defined - As soon as the target shared element (i.e. the shared element in the incoming/target content) is removed, the shared element transition for the shared elements with the same key will be cancelled.

Functions

alternativeTargetBoundsInTransitionScopeAfterRemoval

public fun SharedContentState.alternativeTargetBoundsInTransitionScopeAfterRemoval(
            targetBoundsBeforeRemoval: Rect,
            sharedTransitionLayoutSize: Size,
        ): Rect?

alternativeTargetBoundsInTransitionScopeAfterRemoval returns an alternative target bounds for when the target shared element is disposed amid animation (e.g., scrolled out of the viewport and subsequently disposed).

By default, no alternative target bounds is defined - As soon as the target shared element (i.e. the shared element in the incoming/target content) is removed, the shared element transition for the shared elements with the same key will be cancelled.

Parameters

targetBoundsBeforeRemoval The target bounds of the shared element relative to the SharedTransitionLayout before it is removed.
sharedTransitionLayoutSize The size of the shared transition layout for convenient calculation.