Skip to content

Commit

Permalink
Merge pull request Expensify#33755 from margelo/@chrispader/fix-light…
Browse files Browse the repository at this point in the history
…box-shaking

Fix: Attachment - The image shakes when you zoom in and back to the original size
  • Loading branch information
mountiny authored Jan 10, 2024
2 parents eeb428e + 95f9ab2 commit 55746c7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/MultiGestureCanvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,17 @@ function MultiGestureCanvas({canvasSize, isActive = true, onScaleChanged, childr
// used to store event scale value when we limit scale
const pinchGestureScale = useSharedValue(1);
const pinchGestureRunning = useSharedValue(false);

const [pinchEnabled, setPinchEnabled] = useState(true);
useEffect(() => {
if (pinchEnabled) {
return;
}
setPinchEnabled(true);
}, [pinchEnabled]);

const pinchGesture = Gesture.Pinch()
.enabled(pinchEnabled)
.onTouchesDown((evt, state) => {
// we don't want to activate pinch gesture when we are scrolling pager
if (!isScrolling.value) {
Expand All @@ -466,6 +476,11 @@ function MultiGestureCanvas({canvasSize, isActive = true, onScaleChanged, childr
origin.y.value = adjustFocal.y;
})
.onChange((evt) => {
if (evt.numberOfPointers !== 2) {
runOnJS(setPinchEnabled)(false);
return;
}

const newZoomScale = pinchScaleOffset.value * evt.scale;

if (zoomScale.value >= zoomRange.min * zoomScaleBounceFactors.min && zoomScale.value <= zoomRange.max * zoomScaleBounceFactors.max) {
Expand Down

0 comments on commit 55746c7

Please sign in to comment.