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

Commit d2d9837b authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Skip fling anim if it is a no-op, to save a frame of aniamtion" into ub-launcher3-rvc-dev

parents a41762f8 5112cdd3
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ public class FlingSpringAnim {

    private final FlingAnimation mFlingAnim;
    private SpringAnimation mSpringAnim;
    private final boolean mSkipFlingAnim;

    private float mTargetPosition;

@@ -57,6 +58,10 @@ public class FlingSpringAnim {
                .setMaxValue(maxValue);
        mTargetPosition = targetPosition;

        // We are already past the fling target, so skip it to avoid losing a frame of the spring.
        mSkipFlingAnim = startPosition <= minValue && startVelocity < 0
                || startPosition >= maxValue && startVelocity > 0;

        mFlingAnim.addEndListener(((animation, canceled, value, velocity) -> {
            mSpringAnim = new SpringAnimation(object, property)
                    .setStartValue(value)
@@ -84,6 +89,9 @@ public class FlingSpringAnim {

    public void start() {
        mFlingAnim.start();
        if (mSkipFlingAnim) {
            mFlingAnim.cancel();
        }
    }

    public void end() {