feat(B07): 트랙패드 두 손가락 팬 + 확대를 델타 비례로
확대가 이벤트 1회당 10% 고정이라 트랙패드처럼 잔 델타를 초당 수십 번 보내는 입력에서 튀었고, 두 손가락 이동은 팬이 아니라 확대로 먹혔다. - zoomScreen을 부호 기반에서 델타 비례 지수식 exp(-delta*지수)로 변경. 마우스 휠 한 칸(deltaY 100)은 종전과 같은 10%, 트랙패드 잔 델타는 그만큼만 - 트랙패드 두 손가락 이동은 panScreen으로 — 마우스 휠은 한 칸이 100/120px로 딱 떨어지고 가로 델타가 없다는 성질로 기기를 가른다 - 핀치(ctrl+휠)는 기기 무관 확대, 전용 지수로 천천히 - deltaMode(줄·쪽 단위) 픽셀 환산 추가 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Point, type Vector } from '@flatten-js/core';
|
||||
import { MOUSE_ZOOM_MULTIPLIER } from '../App.consts';
|
||||
import { WHEEL_ZOOM_EXPONENT } from '../App.consts';
|
||||
import { getAngleWithXAxis } from '../helpers/get-angle-with-x-axis.ts';
|
||||
import { getBoundingBoxOfMultipleEntities } from '../helpers/get-bounding-box-of-multiple-entities.ts';
|
||||
import { mapNumberRange } from '../helpers/map-number-range.ts';
|
||||
@@ -107,13 +107,14 @@ export class ScreenCanvasDrawController implements DrawController {
|
||||
* This function takes the deltaY from the mouse wheel event and zooms the screen in or out
|
||||
* The location of the mouse in world space is preserved
|
||||
* @param deltaY
|
||||
* @param exponent 델타 한 단위당 확대 지수 (휠·핀치가 서로 다른 값을 쓴다)
|
||||
*/
|
||||
public zoomScreen(deltaY: number) {
|
||||
public zoomScreen(deltaY: number, exponent: number = WHEEL_ZOOM_EXPONENT) {
|
||||
const worldMouseLocationBeforeZoom = this.getWorldMouseLocation();
|
||||
const oldScreenScale = this.getScreenScale();
|
||||
|
||||
const newScreenScale =
|
||||
oldScreenScale * (1 - MOUSE_ZOOM_MULTIPLIER * (deltaY / Math.abs(deltaY)));
|
||||
// 부호가 아니라 크기까지 본다 — 트랙패드의 잔 델타는 그만큼만 움직인다.
|
||||
const newScreenScale = oldScreenScale * Math.exp(-deltaY * exponent);
|
||||
this.setScreenScale(newScreenScale);
|
||||
|
||||
// now get the location of the cursor in world space again
|
||||
|
||||
Reference in New Issue
Block a user