From aeda009b2fd5880f1ec8aa33041e78a6146b3552 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 31 Oct 2024 14:32:57 +0000 Subject: [PATCH] FIX DA CALCULATION!!!!!! Holy shit this took me a while. Basically we should be treating the original image center as the scale origin rather than the scaled image center. Otherwise expanding feels unsteady. --- src/view/com/lightbox/ImageViewing/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/view/com/lightbox/ImageViewing/index.tsx b/src/view/com/lightbox/ImageViewing/index.tsx index e11dc21b0e..d70aec32ac 100644 --- a/src/view/com/lightbox/ImageViewing/index.tsx +++ b/src/view/com/lightbox/ImageViewing/index.tsx @@ -331,14 +331,14 @@ function interpolateTransform( const thumbnailCenterX = thumbnailDims.pageX + thumbnailDims.width / 2 const thumbnailCenterY = thumbnailDims.pageY + thumbnailDims.height / 2 + const initialTranslateX = thumbnailCenterX - screenCenterX + const initialTranslateY = thumbnailCenterY - screenCenterY const initialScale = thumbnailDims.width / screenSize.width - const initialTranslateX = (thumbnailCenterX - screenCenterX) / initialScale - const initialTranslateY = (thumbnailCenterY - screenCenterY) / initialScale - const scale = interpolate(progress, [0, 1], [initialScale, 1]) const translateX = interpolate(progress, [0, 1], [initialTranslateX, 0]) const translateY = interpolate(progress, [0, 1], [initialTranslateY, 0]) - return [{scale}, {translateX}, {translateY}] + const scale = interpolate(progress, [0, 1], [initialScale, 1]) + return [{translateX}, {translateY}, {scale}] } const styles = StyleSheet.create({