Skip to content

Commit

Permalink
fix: use shared values for minScale/maxScale
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivanka Todorova committed Feb 2, 2022
1 parent ce7b264 commit 0f450fb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ export default forwardRef(function PanPinchView(
}

isPinching.value = true;
scale.value = Math.max(scale.value * event.scaleChange, minScale);
scale.value = Math.max(
scale.value * event.scaleChange,
currentMinScale.value
);

setAdjustedFocal({ focalX: event.focalX, focalY: event.focalY });

Expand All @@ -221,8 +224,13 @@ export default forwardRef(function PanPinchView(

lastScale.value = scale.value;

if (lastScale.value > maxScale || lastScale.value < minScale) {
scale.value = withTiming(clamp(scale.value, minScale, maxScale));
if (
lastScale.value > currentMaxScale.value ||
lastScale.value < currentMinScale.value
) {
scale.value = withTiming(
clamp(scale.value, currentMinScale.value, currentMaxScale.value)
);
}
}
});
Expand Down

0 comments on commit 0f450fb

Please sign in to comment.