From 02ddb7a2f7398ec1fa9faeb29fb39354d3b7bf0b Mon Sep 17 00:00:00 2001 From: Francesco Cretti Date: Wed, 20 Jun 2018 18:45:38 +0200 Subject: [PATCH] preventDefaultAction in canvas-drag on minimap --- src/navigator.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index 4c9848cf..6c05e3f7 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -417,8 +417,36 @@ function onCanvasClick( event ) { * @function */ function onCanvasDrag( event ) { - if ( this.viewer.viewport ) { - if( !this.panHorizontal ){ + var canvasDragEventArgs = { + tracker: event.eventSource, + position: event.position, + delta: event.delta, + speed: event.speed, + direction: event.direction, + shift: event.shift, + originalEvent: event.originalEvent, + preventDefaultAction: event.preventDefaultAction + }; + /** + * Raised when a click event occurs on the {@link OpenSeadragon.Viewer#navigator} element. + * + * @event navigator-click + * @memberof OpenSeadragon.Viewer + * @type {object} + * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event. + * @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event. + * @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element. + * @property {Boolean} quick - True only if the clickDistThreshold and clickTimeThreshold are both passed. Useful for differentiating between clicks and drags. + * @property {Boolean} shift - True if the shift key was pressed during this event. + * @property {Object} originalEvent - The original DOM event. + * @property {?Object} userData - Arbitrary subscriber-defined object. + * @property {Boolean} preventDefaultAction - Set to true to prevent default click to zoom behaviour. Default: false. + */ + + this.viewer.raiseEvent('navigator-drag', canvasDragEventArgs); + + if ( !canvasDragEventArgs.preventDefaultAction && this.viewer.viewport ) { + if( !this.panHorizontal ){ event.delta.x = 0; } if( !this.panVertical ){