Skip to content

Commit

Permalink
트랙패드 줌인줌아웃 방향 수정 (#164)
Browse files Browse the repository at this point in the history
* fix: 트랙패드 줌인줌아웃 반대방향으로 동작하던 것 수정

* fix: 트랙패드 / ctrl+마우스휠만 허용하는 것으로 최종변경
  • Loading branch information
CatyJazzy authored Nov 28, 2024
1 parent f6a6005 commit cd0c601
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/frontend/src/hooks/useZoomSpace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ export function useZoomSpace({
const zoomSpace = (event: KonvaEventObject<WheelEvent>) => {
event.evt.preventDefault();

if (!event.evt.ctrlKey && !event.evt.metaKey) {
const isControlWheelZoom =
event.evt.deltaMode === WheelEvent.DOM_DELTA_LINE && event.evt.ctrlKey;
const isTrackpadGesture =
event.evt.deltaMode === WheelEvent.DOM_DELTA_PIXEL && event.evt.ctrlKey;

// NOTE - 마우스휠 동작 방향 반대로 수정할 수 있는지 검토 필요
// [ctrl + 마우스휠] 또는 [트랙패드 제스처]만 허용
if (!isControlWheelZoom && !isTrackpadGesture) {
return;
}

Expand All @@ -63,7 +70,8 @@ export function useZoomSpace({
if (!pointer) return;

const mousePointTo = getMousePointTo(stage, pointer, oldScale);
let newScale = calculateNewScale(oldScale, event.evt.deltaY, scaleBy);

let newScale = calculateNewScale(oldScale, -event.evt.deltaY, scaleBy);

newScale = Math.max(minScale, Math.min(maxScale, newScale));

Expand Down

0 comments on commit cd0c601

Please sign in to comment.