diff --git a/changelog.txt b/changelog.txt index fae18ba3..e935148a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,9 @@ 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) * You can now flip the viewport to get a mirror image of the original (#1441) @@ -16,7 +18,11 @@ OPENSEADRAGON CHANGELOG * 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) * 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: * Debug mode now uses different colors for different tiled images (customizable via debugGridColor) (#1271) diff --git a/package.json b/package.json index a85bfdde..75a054cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openseadragon", - "version": "2.3.1", + "version": "2.4.0", "description": "Provides a smooth, zoomable user interface for HTML/Javascript.", "keywords": [ "image", diff --git a/src/dzitilesource.js b/src/dzitilesource.js index ec5ea9a9..ee862f0d 100644 --- a/src/dzitilesource.js +++ b/src/dzitilesource.js @@ -182,6 +182,10 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, /** @lends OpenSead yMax, i; + if ((this.minLevel && level < this.minLevel) || (this.maxLevel && level > this.maxLevel)) { + return false; + } + if ( !rects || !rects.length ) { return true; } diff --git a/src/navigator.js b/src/navigator.js index abce42d4..c1bfc6f1 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -428,13 +428,48 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /* * @function */ function onCanvasClick( event ) { - if ( event.quick && this.viewer.viewport ) { - if(this.viewer.viewport.flipped){ - event.position.x = this.viewport.getContainerSize().x - event.position.x; - } - this.viewer.viewport.panTo(this.viewport.pointFromPixel(event.position)); - 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. + * + * @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(); + } + } /** @@ -443,8 +478,37 @@ 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 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 ){ event.delta.x = 0; } if( !this.panVertical ){ diff --git a/src/tiledimage.js b/src/tiledimage.js index 6fb68413..52012071 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -972,6 +972,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag // Calculations for the interval of levels to draw // can return invalid intervals; fix that here if necessary + highestLevel = Math.max(highestLevel, this.source.minLevel || 0); lowestLevel = Math.min(lowestLevel, highestLevel); return { lowestLevel: lowestLevel,