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

Commit 4c19a7cc authored by George Mount's avatar George Mount
Browse files

Limit overscroll stretch for animation

Bug: 192465706

Stretch overscroll was allowing pull distances beyond 1, but
the effect only applied until 1. This meant that as the stretch
relaxed, it would appear stopped at 1 until it dropped below 1.

This CL does two things. First, it limits the pull distance
to 1, so that if it is pulled beyond 1, the distance remains
1 and the spring will immediately retract from 1 with onRelease().
Second, when the fling hits 1, it stops the fling animation and
immediately begins retracting from a velocity of 0.

Test: new tests and manual testing for visual effect
Test: I23cd8990fff24dbef36a93c16c115948d774a557
Change-Id: I06f1533aed0ce24756c535789fdcc7e99c5bfb9b
parent 8fd5255f
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -365,6 +365,10 @@ public class EdgeEffect {
        mDuration = PULL_TIME;
        mDuration = PULL_TIME;


        mPullDistance += deltaDistance;
        mPullDistance += deltaDistance;
        if (edgeEffectBehavior == TYPE_STRETCH) {
            // Don't allow stretch beyond 1
            mPullDistance = Math.min(1f, mPullDistance);
        }
        mDistance = Math.max(0f, mPullDistance);
        mDistance = Math.max(0f, mPullDistance);
        mVelocity = 0;
        mVelocity = 0;


@@ -783,6 +787,10 @@ public class EdgeEffect {
                + mDampedFreq * sinCoeff * Math.cos(mDampedFreq * deltaT));
                + mDampedFreq * sinCoeff * Math.cos(mDampedFreq * deltaT));
        mDistance = (float) distance / mHeight;
        mDistance = (float) distance / mHeight;
        mVelocity = (float) velocity;
        mVelocity = (float) velocity;
        if (mDistance > 1f) {
            mDistance = 1f;
            mVelocity = 0f;
        }
        if (isAtEquilibrium()) {
        if (isAtEquilibrium()) {
            mDistance = 0;
            mDistance = 0;
            mVelocity = 0;
            mVelocity = 0;