fix: Two finger panning is slow (#7849)

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
zsviczian 2024-05-19 14:23:43 +02:00 committed by GitHub
parent ff0b4394b1
commit be4e127f6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View file

@ -5097,8 +5097,11 @@ class App extends React.Component<AppProps, AppState> {
this.translateCanvas({ this.translateCanvas({
zoom: zoomState.zoom, zoom: zoomState.zoom,
scrollX: zoomState.scrollX + deltaX / nextZoom, // 2x multiplier is just a magic number that makes this work correctly
scrollY: zoomState.scrollY + deltaY / nextZoom, // 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, shouldCacheIgnoreZoom: true,
}); });
}); });

View file

@ -10752,7 +10752,7 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = `
"pendingImageElementId": null, "pendingImageElementId": null,
"previousSelectedElementIds": {}, "previousSelectedElementIds": {},
"resizingElement": null, "resizingElement": null,
"scrollX": -2.916666666666668, "scrollX": -6.2500000000000036,
"scrollY": 0, "scrollY": 0,
"scrolledOutside": false, "scrolledOutside": false,
"selectedElementIds": {}, "selectedElementIds": {},
@ -13688,8 +13688,8 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`]
"pendingImageElementId": null, "pendingImageElementId": null,
"previousSelectedElementIds": {}, "previousSelectedElementIds": {},
"resizingElement": null, "resizingElement": null,
"scrollX": 10, "scrollX": 20,
"scrollY": -10, "scrollY": -18.535533905932738,
"scrolledOutside": false, "scrolledOutside": false,
"selectedElementIds": {}, "selectedElementIds": {},
"selectedElementsAreBeingDragged": false, "selectedElementsAreBeingDragged": false,