Fix spring-loaded folder animation offset bug

The folder close animation is offset due incorrect scaling in SpringLoaded mode. We fix the folder offset by scaling offsetX() and offsetY() by the scale of the workspace in spring loaded mode (scaleRelativeToDragLayer), and the offset of the preview icons is fixed by dividing previewItemOffsetX by initialScale rather than initialScale / scaleRelativeToDragLayer

Fix: 255420905
Test: manual
Change-Id: I305c1047c14c4c9f1b4c3bd0143e9bb764c71524
This commit is contained in:
Federico Baron
2022-11-11 11:38:40 -08:00
parent 6a2dd438da
commit c7e76005e0

View File

@@ -168,9 +168,11 @@ public class FolderAnimationManager {
final int paddingOffsetY = (int) (mContent.getPaddingTop() * initialScale);
int initialX = folderIconPos.left + mFolder.getPaddingLeft()
+ mPreviewBackground.getOffsetX() - paddingOffsetX - previewItemOffsetX;
+ Math.round(mPreviewBackground.getOffsetX() * scaleRelativeToDragLayer)
- paddingOffsetX - previewItemOffsetX;
int initialY = folderIconPos.top + mFolder.getPaddingTop()
+ mPreviewBackground.getOffsetY() - paddingOffsetY;
+ Math.round(mPreviewBackground.getOffsetY() * scaleRelativeToDragLayer)
- paddingOffsetY;
final float xDistance = initialX - lp.x;
final float yDistance = initialY - lp.y;
@@ -313,7 +315,7 @@ public class FolderAnimationManager {
addPreviewItemAnimators(a, initialScale / scaleRelativeToDragLayer,
// Background can have a scaled radius in drag and drop mode, so we need to add the
// difference to keep the preview items centered.
previewItemOffsetX + radiusDiff, radiusDiff);
(int) (previewItemOffsetX / scaleRelativeToDragLayer) + radiusDiff, radiusDiff);
return a;
}