This commit is contained in:
Peter 2018-07-23 13:58:23 -04:00
commit d353580471
5 changed files with 86 additions and 11 deletions

View File

@ -1,7 +1,9 @@
OPENSEADRAGON CHANGELOG OPENSEADRAGON CHANGELOG
======================= =======================
2.4.0: (In Progress) 2.4.1: (In progress)
2.4.0:
* BREAKING CHANGE: Viewer's canvas-double-click event is now fired before it initiates the zoom (#1288) * BREAKING CHANGE: Viewer's canvas-double-click event is now fired before it initiates the zoom (#1288)
* You can now flip the viewport to get a mirror image of the original (#1441) * You can now flip the viewport to get a mirror image of the original (#1441)
@ -16,6 +18,10 @@ OPENSEADRAGON CHANGELOG
* Fixed an issue causing the simple image tileSource to sometimes show duplicate copies (#1370) * Fixed an issue causing the simple image tileSource to sometimes show duplicate copies (#1370)
* Fixed an issue causing seams to appear in semi-transparent PNG tiled images (#1470) * Fixed an issue causing seams to appear in semi-transparent PNG tiled images (#1470)
* Added visual customization options for the navigator (#1480) * Added visual customization options for the navigator (#1480)
* You can now prevent canvas-drag events on the navigator (#1484)
* You can now prevent canvas-click events on the navigator (#1416)
* The navigator can now be restricted to just horizontal or just vertical panning (#1416)
* Fixed DziTileSource so it doesn't load levels above maxLevel or below minLevel, if set (#1492)
2.3.1: 2.3.1:

View File

@ -1,6 +1,6 @@
{ {
"name": "openseadragon", "name": "openseadragon",
"version": "2.3.1", "version": "2.4.0",
"description": "Provides a smooth, zoomable user interface for HTML/Javascript.", "description": "Provides a smooth, zoomable user interface for HTML/Javascript.",
"keywords": [ "keywords": [
"image", "image",

View File

@ -182,6 +182,10 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, /** @lends OpenSead
yMax, yMax,
i; i;
if ((this.minLevel && level < this.minLevel) || (this.maxLevel && level > this.maxLevel)) {
return false;
}
if ( !rects || !rects.length ) { if ( !rects || !rects.length ) {
return true; return true;
} }

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 = {
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) { 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();
} }
} }
/** /**
@ -443,7 +478,36 @@ function onCanvasClick( event ) {
* @function * @function
*/ */
function onCanvasDrag( event ) { function onCanvasDrag( event ) {
if ( this.viewer.viewport ) { 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 drag event occurs on the {@link OpenSeadragon.Viewer#navigator} element.
*
* @event navigator-drag
* @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 {OpenSeadragon.Point} delta - The x,y components of the difference between start drag and end drag.
* @property {Number} speed - Current computed speed, in pixels per second.
* @property {Number} direction - Current computed direction, expressed as an angle counterclockwise relative to the positive X axis (-pi to pi, in radians). Only valid if speed > 0.
* @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 ){ if( !this.panHorizontal ){
event.delta.x = 0; event.delta.x = 0;
} }

View File

@ -972,6 +972,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
// Calculations for the interval of levels to draw // Calculations for the interval of levels to draw
// can return invalid intervals; fix that here if necessary // can return invalid intervals; fix that here if necessary
highestLevel = Math.max(highestLevel, this.source.minLevel || 0);
lowestLevel = Math.min(lowestLevel, highestLevel); lowestLevel = Math.min(lowestLevel, highestLevel);
return { return {
lowestLevel: lowestLevel, lowestLevel: lowestLevel,