Skip to content

Commit

Permalink
fix: Two finger panning is slow (#7849)
Browse files Browse the repository at this point in the history
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
  • Loading branch information
zsviczian and dwelle committed May 19, 2024
1 parent ff0b439 commit be4e127
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions packages/excalidraw/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5097,8 +5097,11 @@ class App extends React.Component<AppProps, AppState> {

this.translateCanvas({
zoom: zoomState.zoom,
scrollX: zoomState.scrollX + deltaX / nextZoom,
scrollY: zoomState.scrollY + deltaY / nextZoom,
// 2x multiplier is just a magic number that makes this work correctly
// on touchscreen devices (note: if we get report that panning is slower/faster
// than actual movement, consider swapping with devicePixelRatio)
scrollX: zoomState.scrollX + 2 * (deltaX / nextZoom),
scrollY: zoomState.scrollY + 2 * (deltaY / nextZoom),
shouldCacheIgnoreZoom: true,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10752,7 +10752,7 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = `
"pendingImageElementId": null,
"previousSelectedElementIds": {},
"resizingElement": null,
"scrollX": -2.916666666666668,
"scrollX": -6.2500000000000036,
"scrollY": 0,
"scrolledOutside": false,
"selectedElementIds": {},
Expand Down Expand Up @@ -13688,8 +13688,8 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`]
"pendingImageElementId": null,
"previousSelectedElementIds": {},
"resizingElement": null,
"scrollX": 10,
"scrollY": -10,
"scrollX": 20,
"scrollY": -18.535533905932738,
"scrolledOutside": false,
"selectedElementIds": {},
"selectedElementsAreBeingDragged": false,
Expand Down

0 comments on commit be4e127

Please sign in to comment.