Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt +3 −3 Original line number Diff line number Diff line Loading @@ -543,7 +543,8 @@ private fun SwipeTransition(old: SwipeTransition): SwipeTransition { _toScene = old._toScene, userActionDistanceScope = old.userActionDistanceScope, orientation = old.orientation, isUpOrLeft = old.isUpOrLeft isUpOrLeft = old.isUpOrLeft, lastDistance = old.lastDistance, ) .apply { _currentScene = old._currentScene Loading @@ -561,6 +562,7 @@ private class SwipeTransition( val userActionDistanceScope: UserActionDistanceScope, override val orientation: Orientation, override val isUpOrLeft: Boolean, var lastDistance: Float = DistanceUnspecified, ) : TransitionState.Transition(_fromScene.key, _toScene.key), TransitionState.HasOverscrollProperties { Loading Loading @@ -620,8 +622,6 @@ private class SwipeTransition( get() = distance().absoluteValue } private var lastDistance = DistanceUnspecified /** Whether [TransitionState.Transition.finish] was called on this transition. */ var isFinishing = false private set Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt +1 −1 Original line number Diff line number Diff line Loading @@ -461,7 +461,7 @@ data class UserActionResult( val transitionKey: TransitionKey? = null, ) interface UserActionDistance { fun interface UserActionDistance { /** * Return the **absolute** distance of the user action given the size of the scene we are * animating from and the [orientation]. Loading packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt +19 −0 Original line number Diff line number Diff line Loading @@ -1195,4 +1195,23 @@ class DraggableHandlerTest { assertThat(transition).hasProgress(0f) assertThat(transition).hasOverscrollSpec() } @Test fun interceptingTransitionKeepsDistance() = runGestureTest { var swipeDistance = 75f layoutState.transitions = transitions { from(SceneA, to = SceneB) { distance = UserActionDistance { _, _ -> swipeDistance } } } // Start transition. val controller = onDragStarted(overSlop = -50f) assertTransition(fromScene = SceneA, toScene = SceneB, progress = 50f / 75f) // Intercept the transition and change the swipe distance. The original distance and // progress should be the same. swipeDistance = 50f controller.onDragStopped(0f) onDragStartedImmediately() assertTransition(fromScene = SceneA, toScene = SceneB, progress = 50f / 75f) } } Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt +3 −3 Original line number Diff line number Diff line Loading @@ -543,7 +543,8 @@ private fun SwipeTransition(old: SwipeTransition): SwipeTransition { _toScene = old._toScene, userActionDistanceScope = old.userActionDistanceScope, orientation = old.orientation, isUpOrLeft = old.isUpOrLeft isUpOrLeft = old.isUpOrLeft, lastDistance = old.lastDistance, ) .apply { _currentScene = old._currentScene Loading @@ -561,6 +562,7 @@ private class SwipeTransition( val userActionDistanceScope: UserActionDistanceScope, override val orientation: Orientation, override val isUpOrLeft: Boolean, var lastDistance: Float = DistanceUnspecified, ) : TransitionState.Transition(_fromScene.key, _toScene.key), TransitionState.HasOverscrollProperties { Loading Loading @@ -620,8 +622,6 @@ private class SwipeTransition( get() = distance().absoluteValue } private var lastDistance = DistanceUnspecified /** Whether [TransitionState.Transition.finish] was called on this transition. */ var isFinishing = false private set Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt +1 −1 Original line number Diff line number Diff line Loading @@ -461,7 +461,7 @@ data class UserActionResult( val transitionKey: TransitionKey? = null, ) interface UserActionDistance { fun interface UserActionDistance { /** * Return the **absolute** distance of the user action given the size of the scene we are * animating from and the [orientation]. Loading
packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt +19 −0 Original line number Diff line number Diff line Loading @@ -1195,4 +1195,23 @@ class DraggableHandlerTest { assertThat(transition).hasProgress(0f) assertThat(transition).hasOverscrollSpec() } @Test fun interceptingTransitionKeepsDistance() = runGestureTest { var swipeDistance = 75f layoutState.transitions = transitions { from(SceneA, to = SceneB) { distance = UserActionDistance { _, _ -> swipeDistance } } } // Start transition. val controller = onDragStarted(overSlop = -50f) assertTransition(fromScene = SceneA, toScene = SceneB, progress = 50f / 75f) // Intercept the transition and change the swipe distance. The original distance and // progress should be the same. swipeDistance = 50f controller.onDragStopped(0f) onDragStartedImmediately() assertTransition(fromScene = SceneA, toScene = SceneB, progress = 50f / 75f) } }