Merge pull request #1956 from openseadragon/ms-gesturesettings

Added dragToPan to the GestureSettings class
This commit is contained in:
Ian Gilman 2021-03-16 13:40:26 -07:00 committed by GitHub
commit 733f851ad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 13 deletions

View File

@ -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:

View File

@ -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;
}
/**

View File

@ -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,

View File

@ -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;
}

View File

@ -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;
}