diff options
2 files changed, 8 insertions, 9 deletions
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt index 5b328b8cdd9c..fb13b57176c6 100644 --- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt +++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt @@ -712,9 +712,7 @@ private class SwipeTransition( val hasReachedTargetScene = (targetScene == toScene && progress >= 1f) || (targetScene == fromScene && progress <= 0f) - val skipAnimation = - hasReachedTargetScene && - currentOverscrollSpec?.transformationSpec?.transformations?.isEmpty() == true + val skipAnimation = hasReachedTargetScene && !canOverscroll() return startOffsetAnimation { val animatable = Animatable(dragOffset, OffsetVisibilityThreshold) @@ -767,12 +765,7 @@ private class SwipeTransition( // Immediately stop this transition if we are bouncing on a // scene that does not bounce. - val overscrollSpec = currentOverscrollSpec - if ( - overscrollSpec != null && - overscrollSpec.transformationSpec.transformations - .isEmpty() - ) { + if (!canOverscroll()) { snapToScene(targetScene) } } diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt index 08e8e7250e0c..2a739d78ccc1 100644 --- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt +++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt @@ -233,6 +233,12 @@ sealed interface TransitionState { } } + /** Returns if the [progress] value of this transition can go beyond range `[0; 1]` */ + fun canOverscroll(): Boolean { + val overscrollSpec = currentOverscrollSpec ?: return true + return overscrollSpec.transformationSpec.transformations.isNotEmpty() + } + /** * An animatable that animates from 1f to 0f. This will be used to nicely animate the sudden * jump of values when this transitions interrupts another one. |