mirror of
				https://github.com/excalidraw/excalidraw.git
				synced 2025-11-04 04:44:31 +01:00 
			
		
		
		
	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:
		@@ -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;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user