Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cde6419b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add Transition.canOverscroll()" into main

parents c73eb267 d163a3a5
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -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)
                                        }
                                    }
+6 −0
Original line number Diff line number Diff line
@@ -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.