class OnSwipe


Defines the OnSwipe behavior for a Transition.

 

When swiping, the MotionLayout is updated to a progress value so that the given ConstrainedLayoutReference is laid out in a position corresponding to the drag.

In other words, OnSwipe allows you to drive MotionLayout by dragging a specific ConstrainedLayoutReference.

Summary

Public constructors

OnSwipe(
    anchor: ConstrainedLayoutReference,
    side: SwipeSide,
    direction: SwipeDirection,
    dragScale: Float,
    dragThreshold: Float,
    dragAround: ConstrainedLayoutReference?,
    limitBoundsTo: ConstrainedLayoutReference?,
    onTouchUp: SwipeTouchUp,
    mode: SwipeMode
)

Public properties

ConstrainedLayoutReference

The ConstrainedLayoutReference to track through touch input.

SwipeDirection

Expected swipe direction to start the animation through touch handling.

ConstrainedLayoutReference?

When not-null, causes the anchor to be dragged around the center of the given ConstrainedLayoutReference in a circular motion.

Float

Scaling factor applied on the dragged distance, meaning that the larger the scaling value, the shorter distance is required to animate the entire Transition.

Float

Distance in pixels required to consider the drag as initiated.

ConstrainedLayoutReference?

When not-null, the touch handling won't be initiated unless it's within the bounds of the given ConstrainedLayoutReference.

SwipeMode

Describes how MotionLayout animates during onTouchUp.

SwipeTouchUp

Defines what behavior MotionLayout should have when the drag event is interrupted by TouchUp.

SwipeSide

Side of the bounds to track, this is to account for when the tracked widget changes size during the Transition.

Public constructors

OnSwipe

Added in 1.1.0-alpha13
OnSwipe(
    anchor: ConstrainedLayoutReference,
    side: SwipeSide,
    direction: SwipeDirection,
    dragScale: Float = 1.0f,
    dragThreshold: Float = 10.0f,
    dragAround: ConstrainedLayoutReference? = null,
    limitBoundsTo: ConstrainedLayoutReference? = null,
    onTouchUp: SwipeTouchUp = SwipeTouchUp.AutoComplete,
    mode: SwipeMode = SwipeMode.velocity()
)
Parameters
anchor: ConstrainedLayoutReference

The ConstrainedLayoutReference to track through touch input.

side: SwipeSide

Side of the bounds to track, this is to account for when the tracked widget changes size during the Transition.

direction: SwipeDirection

Expected swipe direction to start the animation through touch handling. Typically, this is the direction the widget takes to the end ConstraintSet.

dragScale: Float = 1.0f

Scaling factor applied on the dragged distance, meaning that the larger the scaling value, the shorter distance is required to animate the entire Transition. 1f by default.

dragThreshold: Float = 10.0f

Distance in pixels required to consider the drag as initiated. 10 by default.

dragAround: ConstrainedLayoutReference? = null

When not-null, causes the anchor to be dragged around the center of the given ConstrainedLayoutReference in a circular motion.

limitBoundsTo: ConstrainedLayoutReference? = null

When not-null, the touch handling won't be initiated unless it's within the bounds of the given ConstrainedLayoutReference. Useful to deal with touch handling conflicts.

onTouchUp: SwipeTouchUp = SwipeTouchUp.AutoComplete

Defines what behavior MotionLayout should have when the drag event is interrupted by TouchUp. SwipeTouchUp.AutoComplete by default.

mode: SwipeMode = SwipeMode.velocity()

Describes how MotionLayout animates during onTouchUp. SwipeMode.velocity by default.

Public properties

anchor

Added in 1.1.0-alpha13
val anchorConstrainedLayoutReference

The ConstrainedLayoutReference to track through touch input.

direction

Added in 1.1.0-alpha13
val directionSwipeDirection

Expected swipe direction to start the animation through touch handling. Typically, this is the direction the widget takes to the end ConstraintSet.

dragAround

Added in 1.1.0-alpha13
val dragAroundConstrainedLayoutReference?

When not-null, causes the anchor to be dragged around the center of the given ConstrainedLayoutReference in a circular motion.

dragScale

Added in 1.1.0-alpha13
val dragScaleFloat

Scaling factor applied on the dragged distance, meaning that the larger the scaling value, the shorter distance is required to animate the entire Transition. 1f by default.

dragThreshold

Added in 1.1.0-alpha13
val dragThresholdFloat

Distance in pixels required to consider the drag as initiated. 10 by default.

limitBoundsTo

Added in 1.1.0-alpha13
val limitBoundsToConstrainedLayoutReference?

When not-null, the touch handling won't be initiated unless it's within the bounds of the given ConstrainedLayoutReference. Useful to deal with touch handling conflicts.

mode

Added in 1.1.0-alpha13
val modeSwipeMode

Describes how MotionLayout animates during onTouchUp. SwipeMode.velocity by default.

onTouchUp

Added in 1.1.0-alpha13
val onTouchUpSwipeTouchUp

Defines what behavior MotionLayout should have when the drag event is interrupted by TouchUp. SwipeTouchUp.AutoComplete by default.

side

Added in 1.1.0-alpha13
val sideSwipeSide

Side of the bounds to track, this is to account for when the tracked widget changes size during the Transition.