mirror of https://github.com/tooot-app/app
39 lines
1.2 KiB
Diff
39 lines
1.2 KiB
Diff
diff --git a/src/zoom.tsx b/src/zoom.tsx
|
|
index 70ce1c8d6a43e711f06b93d1eda3b44a3ad9a659..cdc2713470f2d332b8bf3e9c97e38fd9b78281df 100644
|
|
--- a/src/zoom.tsx
|
|
+++ b/src/zoom.tsx
|
|
@@ -4,6 +4,7 @@ import Animated, {
|
|
useSharedValue,
|
|
useAnimatedStyle,
|
|
useDerivedValue,
|
|
+ withDecay,
|
|
withTiming,
|
|
cancelAnimation,
|
|
runOnJS,
|
|
@@ -120,11 +121,22 @@ export function Zoom(props: Props) {
|
|
}
|
|
}
|
|
})
|
|
- .onEnd(() => {
|
|
+ .onEnd((event) => {
|
|
if (isPinching.value || !isZoomed.value) return;
|
|
|
|
- panTranslateX.value = 0;
|
|
- panTranslateY.value = 0;
|
|
+ const maxTranslateX = (viewWidth.value / 2) * scale.value - viewWidth.value / 2;
|
|
+ const minTranslateX = -maxTranslateX;
|
|
+ translationX.value = withDecay({
|
|
+ velocity: event.velocityX,
|
|
+ clamp: [minTranslateX, maxTranslateX]
|
|
+ });
|
|
+
|
|
+ const maxTranslateY = (viewHeight.value / 2) * scale.value - viewHeight.value / 2;
|
|
+ const minTranslateY = -maxTranslateY;
|
|
+ translationY.value = withDecay({
|
|
+ velocity: event.velocityY,
|
|
+ clamp: [minTranslateY, maxTranslateY]
|
|
+ });
|
|
});
|
|
|
|
const pinch = Gesture.Pinch()
|