Skip to content

Commit

Permalink
apply Tomek suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
sumo-slonik committed Nov 26, 2024
1 parent f631cb9 commit 954560c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/MultiGestureCanvas/usePanGesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ const usePanGesture = ({
}
}

if (previousTouchValue === null) {
if (previousTouch.get() === null) {
previousTouch.set({
x: evt.allTouches.at(0)?.x ?? 0,
y: evt.allTouches.at(0)?.y ?? 0,
Expand Down
5 changes: 2 additions & 3 deletions src/components/MultiGestureCanvas/usePinchGesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ const usePinchGesture = ({
}

const newZoomScale = pinchScale.get() * evt.scale;
const zoomScaleValue = zoomScale.get();
// Limit the zoom scale to zoom range including bounce range
if (zoomScaleValue >= zoomRange.min * ZOOM_RANGE_BOUNCE_FACTORS.min && zoomScaleValue <= zoomRange.max * ZOOM_RANGE_BOUNCE_FACTORS.max) {
if (zoomScale.get() >= zoomRange.min * ZOOM_RANGE_BOUNCE_FACTORS.min && zoomScale.get() <= zoomRange.max * ZOOM_RANGE_BOUNCE_FACTORS.max) {
zoomScale.set(newZoomScale);
currentPinchScale.set(evt.scale);

Expand All @@ -144,7 +143,7 @@ const usePinchGesture = ({

// If the zoom scale is within the zoom range, we perform the regular pinch translation
// Otherwise it means that we are "overzoomed" or "underzoomed", so we need to bounce back
if (zoomScaleValue >= zoomRange.min && zoomScaleValue <= zoomRange.max) {
if (zoomScale.get() >= zoomRange.min && zoomScale.get() <= zoomRange.max) {
pinchTranslateX.set(newPinchTranslateX);
pinchTranslateY.set(newPinchTranslateY);
} else {
Expand Down

0 comments on commit 954560c

Please sign in to comment.