fix: View mode wheel zooming does not work (#8452)

* Update App.tsx

* fix: prevent zooming browser over DOM

---------

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
zsviczian 2024-08-31 12:06:38 +02:00 committed by GitHub
parent ee30225062
commit 2d1d84a47b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 8 deletions

View File

@ -2515,7 +2515,7 @@ class App extends React.Component<AppProps, AppState> {
addEventListener(
this.excalidrawContainerRef.current,
EVENT.WHEEL,
this.onWheel,
this.handleWheel,
{ passive: false },
),
addEventListener(window, EVENT.MESSAGE, this.onWindowMessage, false),
@ -4323,13 +4323,6 @@ class App extends React.Component<AppProps, AppState> {
},
);
private onWheel = withBatchedUpdates((event: WheelEvent) => {
// prevent browser pinch zoom on DOM elements
if (!(event.target instanceof HTMLCanvasElement) && event.ctrlKey) {
event.preventDefault();
}
});
private onKeyUp = withBatchedUpdates((event: KeyboardEvent) => {
if (event.key === KEYS.SPACE) {
if (this.state.viewModeEnabled) {
@ -10089,6 +10082,11 @@ class App extends React.Component<AppProps, AppState> {
event.target instanceof HTMLIFrameElement
)
) {
// prevent zooming the browser (but allow scrolling DOM)
if (event[KEYS.CTRL_OR_CMD]) {
event.preventDefault();
}
return;
}