From 870d9df77960e05ed853b3779023ff954f66c642 Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Tue, 16 Mar 2021 19:47:08 -0700 Subject: [PATCH] Code cleanup, better scrollHandler handling in Viewer --- src/mousetracker.js | 1 - src/viewer.js | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mousetracker.js b/src/mousetracker.js index abd33fdd..f4214a27 100644 --- a/src/mousetracker.js +++ b/src/mousetracker.js @@ -2089,7 +2089,6 @@ if ( eventInfo.stopPropagation ) { $.stopEvent( originalEvent ); } - //if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) { if ( ( eventArgs && eventArgs.preventDefault ) || ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) ) { $.cancelEvent( originalEvent ); } diff --git a/src/viewer.js b/src/viewer.js index 4c0465e3..29b2054a 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -3224,7 +3224,8 @@ function onCanvasScroll( event ) { scroll: event.scroll, shift: event.shift, originalEvent: event.originalEvent, - preventDefaultAction: false + preventDefaultAction: false, + preventDefault: true }; /** @@ -3240,6 +3241,7 @@ function onCanvasScroll( event ) { * @property {Boolean} shift - True if the shift key was pressed during this event. * @property {Object} originalEvent - The original DOM event. * @property {Boolean} preventDefaultAction - Set to true to prevent default scroll to zoom behaviour. Default: false. + * @property {Boolean} preventDefault - Set to true to prevent the default user-agent's handling of the wheel event. Default: true. * @property {?Object} userData - Arbitrary subscriber-defined object. */ this.raiseEvent('canvas-scroll', canvasScrollEventArgs ); @@ -3259,9 +3261,11 @@ function onCanvasScroll( event ) { this.viewport.applyConstraints(); } } - } - event.preventDefault = true; + event.preventDefault = canvasScrollEventArgs.preventDefault; + } else { + event.preventDefault = true; + } } function onContainerEnter( event ) {