Merge branch 'master' of github.com:openseadragon/openseadragon

This commit is contained in:
Ian Gilman 2018-06-29 10:37:40 -07:00
commit 68d08d8748

View File

@ -428,13 +428,48 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
* @function * @function
*/ */
function onCanvasClick( event ) { function onCanvasClick( event ) {
if ( event.quick && this.viewer.viewport ) { var canvasClickEventArgs = {
if(this.viewer.viewport.flipped){ tracker: event.eventSource,
event.position.x = this.viewport.getContainerSize().x - event.position.x; position: event.position,
} quick: event.quick,
this.viewer.viewport.panTo(this.viewport.pointFromPixel(event.position)); shift: event.shift,
this.viewer.viewport.applyConstraints(); 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-click', canvasClickEventArgs);
if ( !canvasClickEventArgs.preventDefaultAction && event.quick && this.viewer.viewport && (this.panVertical || this.panHorizontal)) {
if(this.viewer.viewport.flipped) {
event.position.x = this.viewport.getContainerSize().x - event.position.x;
} }
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();
}
} }
/** /**