Interface

SharedTransitionScope.SharedContentConfig

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

Source set: 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.

Properties

isEnabled

Source set: Common
public val SharedContentState.isEnabled: Boolean

isEnabled returns a boolean indicating whether the shared element is enabled. By default, it is true.

shouldKeepEnabledForOngoingAnimation

Source set: Common
public val shouldKeepEnabledForOngoingAnimation: Boolean

shouldKeepEnabledForOngoingAnimation returns a boolean indicating whether the shared element should be enabled for ongoing animation. By default, shared elements will be kept enabled for ongoing animation until the animation is finished. This means disabling shared element while the animation is in-flight will have no effect, unless shouldKeepEnabledForOngoingAnimation is overridden to return false. This default is intended to ensure a continuous experience out-of-the-box by avoiding accidentally removing in-flight animations.

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.

Last updated: