diff --git a/changelog.txt b/changelog.txt index 979366e5..6cf91f4f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -39,6 +39,7 @@ OPENSEADRAGON CHANGELOG * MouseTracker: Added preProcessEventHandler for keydown, keyup, keypress, focus, blur Events (#1951 @msalsbery) * Fixed preventDefaultAction functionality in viewer events (#1953 @msalsbery) * Added setImageFormatsSupported function (#1954 @pandaxtc) +* Added dragToPan to the GestureSettings class, implemented in Viewer (#1956 @msalsbery) 2.4.2: diff --git a/src/navigator.js b/src/navigator.js index 82d2cbad..d088c098 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -230,7 +230,14 @@ $.Navigator = function( options ){ dragHandler: $.delegate( this, onCanvasDrag ), clickHandler: $.delegate( this, onCanvasClick ), releaseHandler: $.delegate( this, onCanvasRelease ), - scrollHandler: $.delegate( this, onCanvasScroll ) + scrollHandler: $.delegate( this, onCanvasScroll ), + preProcessEventHandler: function (eventInfo) { + if (eventInfo.eventType === 'wheel') { + //don't scroll the page up and down if the user is scrolling + //in the navigator + eventInfo.preventDefault = true; + } + } }); this.outerTracker.userData = 'Navigator.outerTracker'; @@ -607,10 +614,6 @@ function onCanvasScroll( event ) { shift: event.shift, originalEvent: event.originalEvent }); - - //don't scroll the page up and down if the user is scrolling - //in the navigator - return false; } /** diff --git a/src/openseadragon.js b/src/openseadragon.js index b26a152c..ff011fb7 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -320,6 +320,7 @@ * * @property {OpenSeadragon.GestureSettings} [gestureSettingsMouse] * Settings for gestures generated by a mouse pointer device. (See {@link OpenSeadragon.GestureSettings}) + * @property {Boolean} [gestureSettingsMouse.dragToPan=true] - Pan on drag gesture * @property {Boolean} [gestureSettingsMouse.scrollToZoom=true] - Zoom on scroll gesture * @property {Boolean} [gestureSettingsMouse.clickToZoom=true] - Zoom on click gesture * @property {Boolean} [gestureSettingsMouse.dblClickToZoom=false] - Zoom on double-click gesture. Note: If set to true @@ -334,6 +335,7 @@ * * @property {OpenSeadragon.GestureSettings} [gestureSettingsTouch] * Settings for gestures generated by a touch pointer device. (See {@link OpenSeadragon.GestureSettings}) + * @property {Boolean} [gestureSettingsMouse.dragToPan=true] - Pan on drag gesture * @property {Boolean} [gestureSettingsTouch.scrollToZoom=false] - Zoom on scroll gesture * @property {Boolean} [gestureSettingsTouch.clickToZoom=false] - Zoom on click gesture * @property {Boolean} [gestureSettingsTouch.dblClickToZoom=true] - Zoom on double-click gesture. Note: If set to true @@ -348,6 +350,7 @@ * * @property {OpenSeadragon.GestureSettings} [gestureSettingsPen] * Settings for gestures generated by a pen pointer device. (See {@link OpenSeadragon.GestureSettings}) + * @property {Boolean} [gestureSettingsMouse.dragToPan=true] - Pan on drag gesture * @property {Boolean} [gestureSettingsPen.scrollToZoom=false] - Zoom on scroll gesture * @property {Boolean} [gestureSettingsPen.clickToZoom=true] - Zoom on click gesture * @property {Boolean} [gestureSettingsPen.dblClickToZoom=false] - Zoom on double-click gesture. Note: If set to true @@ -362,6 +365,7 @@ * * @property {OpenSeadragon.GestureSettings} [gestureSettingsUnknown] * Settings for gestures generated by unknown pointer devices. (See {@link OpenSeadragon.GestureSettings}) + * @property {Boolean} [gestureSettingsMouse.dragToPan=true] - Pan on drag gesture * @property {Boolean} [gestureSettingsUnknown.scrollToZoom=true] - Zoom on scroll gesture * @property {Boolean} [gestureSettingsUnknown.clickToZoom=false] - Zoom on click gesture * @property {Boolean} [gestureSettingsUnknown.dblClickToZoom=true] - Zoom on double-click gesture. Note: If set to true @@ -651,6 +655,9 @@ * @typedef {Object} GestureSettings * @memberof OpenSeadragon * + * @property {Boolean} dragToPan + * Set to false to disable panning on drag gestures. + * * @property {Boolean} scrollToZoom * Set to false to disable zooming on scroll gestures. * @@ -1137,6 +1144,7 @@ function OpenSeadragon( options ){ springStiffness: 6.5, animationTime: 1.2, gestureSettingsMouse: { + dragToPan: true, scrollToZoom: true, clickToZoom: true, dblClickToZoom: false, @@ -1148,6 +1156,7 @@ function OpenSeadragon( options ){ pinchRotate: false }, gestureSettingsTouch: { + dragToPan: true, scrollToZoom: false, clickToZoom: false, dblClickToZoom: true, @@ -1159,6 +1168,7 @@ function OpenSeadragon( options ){ pinchRotate: false }, gestureSettingsPen: { + dragToPan: true, scrollToZoom: false, clickToZoom: true, dblClickToZoom: false, @@ -1170,6 +1180,7 @@ function OpenSeadragon( options ){ pinchRotate: false }, gestureSettingsUnknown: { + dragToPan: true, scrollToZoom: false, clickToZoom: false, dblClickToZoom: true, diff --git a/src/referencestrip.js b/src/referencestrip.js index 80ebf566..738a55ab 100644 --- a/src/referencestrip.js +++ b/src/referencestrip.js @@ -121,7 +121,12 @@ $.ReferenceStrip = function ( options ) { enterHandler: $.delegate( this, onStripEnter ), leaveHandler: $.delegate( this, onStripLeave ), keyDownHandler: $.delegate( this, onKeyDown ), - keyHandler: $.delegate( this, onKeyPress ) + keyHandler: $.delegate( this, onKeyPress ), + preProcessEventHandler: function (eventInfo) { + if (eventInfo.eventType === 'wheel') { + eventInfo.preventDefault = true; + } + } } ); //Controls the position and orientation of the reference strip and sets the @@ -348,7 +353,6 @@ function onStripDrag( event ) { } } } - return false; } @@ -397,8 +401,6 @@ function onStripScroll( event ) { } } } - //cancels event - return false; } @@ -489,7 +491,6 @@ function onStripEnter( event ) { element.style.marginLeft = "0px"; } - return false; } @@ -512,7 +513,6 @@ function onStripLeave( event ) { element.style.marginLeft = "-" + ( $.getElementSize( element ).x / 2 ) + "px"; } - return false; } diff --git a/src/viewer.js b/src/viewer.js index 6e9c65b1..c22d3f34 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -2846,8 +2846,9 @@ function onCanvasDrag( event ) { */ this.raiseEvent( 'canvas-drag', canvasDragEventArgs); - if ( !canvasDragEventArgs.preventDefaultAction && this.viewport ) { - gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); + gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); + + if ( gestureSettings.dragToPan && !canvasDragEventArgs.preventDefaultAction && this.viewport ) { if( !this.panHorizontal ){ event.delta.x = 0; }