preventDefaultAction support

This commit is contained in:
Francesco Cretti 2018-06-20 18:07:43 +02:00
parent 57654cf1cf
commit 2eb6eaf52f

View File

@ -405,18 +405,14 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
* @function
*/
function onCanvasClick( event ) {
if (event.quick && this.viewer.viewport && (this.panVertical || this.panHorizontal)) {
var target = this.viewport.pointFromPixel(event.position);
if (!this.panVertical) {
// perform only horizonal pan
target.y = this.viewer.viewport.getCenter(true).y;
} else if (!this.panHorizontal) {
// perform only vertical pan
target.x = this.viewer.viewport.getCenter(true).x;
}
this.viewer.viewport.panTo(target);
this.viewer.viewport.applyConstraints();
}
var canvasClickEventArgs = {
tracker: event.eventSource,
position: event.position,
quick: event.quick,
shift: event.shift,
originalEvent: event.originalEvent,
preventDefaultAction: event.preventDefaultAction
};
/**
* Raised when a click event occurs on the {@link OpenSeadragon.Viewer#navigator} element.
*
@ -430,14 +426,24 @@ function onCanvasClick( event ) {
* @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-click', {
tracker: event.eventSource,
position: event.position,
quick: event.quick,
shift: event.shift,
originalEvent: event.originalEvent
});
this.viewer.raiseEvent('navigator-click', canvasClickEventArgs);
if ( !canvasClickEventArgs.preventDefaultAction && event.quick && this.viewer.viewport && (this.panVertical || this.panHorizontal)) {
var target = this.viewport.pointFromPixel(event.position);
if (!this.panVertical) {
// perform only horizonal pan
target.y = this.viewer.viewport.getCenter(true).y;
} else if (!this.panHorizontal) {
// perform only vertical pan
target.x = this.viewer.viewport.getCenter(true).x;
}
this.viewer.viewport.panTo(target);
this.viewer.viewport.applyConstraints();
}
}
/**