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

Commit e639860d authored by Hongwei Wang's avatar Hongwei Wang Committed by Android (Google) Code Review
Browse files

Merge "Snap to the closest edge when velocity is 0" into main

parents b513d31f 62c7f1e6
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -416,6 +416,17 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
        // location now.
        mSpringingToTouch = false;

        // Boost the velocityX if it's zero to forcefully push it towards the nearest edge.
        // We don't simply change the xEndValue below since the PhysicsAnimator would rely on the
        // same velocityX to find out which edge to snap to.
        if (velocityX == 0) {
            final int motionCenterX = mPipBoundsState
                    .getMotionBoundsState().getBoundsInMotion().centerX();
            final int displayCenterX = mPipBoundsState
                    .getDisplayBounds().centerX();
            velocityX = (motionCenterX < displayCenterX) ? -0.001f : 0.001f;
        }

        mTemporaryBoundsPhysicsAnimator
                .spring(FloatProperties.RECT_WIDTH, getBounds().width(), mSpringConfig)
                .spring(FloatProperties.RECT_HEIGHT, getBounds().height(), mSpringConfig)
+11 −0
Original line number Diff line number Diff line
@@ -416,6 +416,17 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
        // location now.
        mSpringingToTouch = false;

        // Boost the velocityX if it's zero to forcefully push it towards the nearest edge.
        // We don't simply change the xEndValue below since the PhysicsAnimator would rely on the
        // same velocityX to find out which edge to snap to.
        if (velocityX == 0) {
            final int motionCenterX = mPipBoundsState
                    .getMotionBoundsState().getBoundsInMotion().centerX();
            final int displayCenterX = mPipBoundsState
                    .getDisplayBounds().centerX();
            velocityX = (motionCenterX < displayCenterX) ? -0.001f : 0.001f;
        }

        mTemporaryBoundsPhysicsAnimator
                .spring(FloatProperties.RECT_WIDTH, getBounds().width(), mSpringConfig)
                .spring(FloatProperties.RECT_HEIGHT, getBounds().height(), mSpringConfig)