mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Merge pull request #1416 from francescocretti/hotfix/minimapClick
Navigator minimap onClick vertical/horizontal pan fix
This commit is contained in:
commit
47e95b4d26
@ -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,
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @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;
|
event.position.x = this.viewport.getContainerSize().x - event.position.x;
|
||||||
}
|
}
|
||||||
this.viewer.viewport.panTo(this.viewport.pointFromPixel(event.position));
|
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();
|
this.viewer.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user