Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

트랙패드 줌인줌아웃 방향 수정 #164

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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