From 027dac0d8e46e937e0309d6aa8da6d6e7314aeb3 Mon Sep 17 00:00:00 2001 From: Francesco Cretti Date: Wed, 7 Mar 2018 11:25:33 +0100 Subject: [PATCH 01/13] navigato minimap onClick vertical/horizontal pan fix --- src/navigator.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index 4c9848cf..45b56b6c 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -405,10 +405,26 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /* * @function */ function onCanvasClick( event ) { - if ( event.quick && this.viewer.viewport ) { - this.viewer.viewport.panTo(this.viewport.pointFromPixel(event.position)); - this.viewer.viewport.applyConstraints(); + if (event.quick && this.viewer.viewport && (this.panVertical || this.panHorizontal)) { + var target, + posX, + posY; + if (!this.panVertical) { + // perform only horizonal pan + posX = this.viewport.pointFromPixel(event.position).x; + posY = this.viewport.getCenter().y; + target = new $.Point(posX, posY); + } else if (!this.panHorizontal) { + // perform only vertical pan + posX = this.viewport.getCenter().x; + posY = this.viewport.pointFromPixel(event.position).y; + target = new $.Point(posX, posY); + } else { + target = this.viewport.pointFromPixel(event.position); } + this.viewer.viewport.panTo(target); + this.viewer.viewport.applyConstraints(); + } } /** From 12be95c8c3526f99717dba728a347826da613fcd Mon Sep 17 00:00:00 2001 From: Francesco Cretti Date: Sun, 11 Mar 2018 13:05:19 +0100 Subject: [PATCH 02/13] getCenter fixed when clicking on minimap --- src/navigator.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index 45b56b6c..84e3ad51 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -406,21 +406,13 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /* */ function onCanvasClick( event ) { if (event.quick && this.viewer.viewport && (this.panVertical || this.panHorizontal)) { - var target, - posX, - posY; + var target = this.viewport.pointFromPixel(event.position); if (!this.panVertical) { // perform only horizonal pan - posX = this.viewport.pointFromPixel(event.position).x; - posY = this.viewport.getCenter().y; - target = new $.Point(posX, posY); + target.y = this.viewer.viewport.getCenter(true).y; } else if (!this.panHorizontal) { // perform only vertical pan - posX = this.viewport.getCenter().x; - posY = this.viewport.pointFromPixel(event.position).y; - target = new $.Point(posX, posY); - } else { - target = this.viewport.pointFromPixel(event.position); + target.x = this.viewer.viewport.getCenter(true).x; } this.viewer.viewport.panTo(target); this.viewer.viewport.applyConstraints(); From 57654cf1cf768a3171ff95e614647b66965dbf4d Mon Sep 17 00:00:00 2001 From: Francesco Cretti Date: Sun, 11 Mar 2018 13:24:29 +0100 Subject: [PATCH 03/13] raise event for navigator click --- src/navigator.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/navigator.js b/src/navigator.js index 84e3ad51..392d9e15 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -417,6 +417,27 @@ function onCanvasClick( event ) { this.viewer.viewport.panTo(target); this.viewer.viewport.applyConstraints(); } + /** + * 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. + */ + this.viewer.raiseEvent('navigator-click', { + tracker: event.eventSource, + position: event.position, + quick: event.quick, + shift: event.shift, + originalEvent: event.originalEvent + }); } /** From 2eb6eaf52ff26ecae721fcd4f07e0efe93a62733 Mon Sep 17 00:00:00 2001 From: Francesco Cretti Date: Wed, 20 Jun 2018 18:07:43 +0200 Subject: [PATCH 04/13] preventDefaultAction support --- src/navigator.js | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index 392d9e15..944892d0 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -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(); + } + } /** From 02ddb7a2f7398ec1fa9faeb29fb39354d3b7bf0b Mon Sep 17 00:00:00 2001 From: Francesco Cretti Date: Wed, 20 Jun 2018 18:45:38 +0200 Subject: [PATCH 05/13] preventDefaultAction in canvas-drag on minimap --- src/navigator.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index 4c9848cf..6c05e3f7 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -417,8 +417,36 @@ 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 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-drag', canvasDragEventArgs); + + if ( !canvasDragEventArgs.preventDefaultAction && this.viewer.viewport ) { + if( !this.panHorizontal ){ event.delta.x = 0; } if( !this.panVertical ){ From 0bdc2df8ff3d68f3c83be1c8527a51c56013cd26 Mon Sep 17 00:00:00 2001 From: Francesco Cretti Date: Tue, 26 Jun 2018 13:51:33 +0200 Subject: [PATCH 06/13] Documentations corrected --- src/navigator.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index 6c05e3f7..c321fde1 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -430,13 +430,15 @@ function onCanvasDrag( event ) { /** * Raised when a click event occurs on the {@link OpenSeadragon.Viewer#navigator} element. * - * @event navigator-click + * @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 {Boolean} quick - True only if the clickDistThreshold and clickTimeThreshold are both passed. Useful for differentiating between clicks and drags. + * @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. From ed169086e79dc47d702720abd4ec29eb69a14c9f Mon Sep 17 00:00:00 2001 From: Francesco Cretti Date: Tue, 26 Jun 2018 14:07:52 +0200 Subject: [PATCH 07/13] Doc minor fix and trailing space removed --- src/navigator.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/navigator.js b/src/navigator.js index c321fde1..d6847560 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -428,7 +428,7 @@ function onCanvasDrag( event ) { preventDefaultAction: event.preventDefaultAction }; /** - * Raised when a click event occurs on the {@link OpenSeadragon.Viewer#navigator} element. + * Raised when a drag event occurs on the {@link OpenSeadragon.Viewer#navigator} element. * * @event navigator-drag * @memberof OpenSeadragon.Viewer @@ -444,7 +444,6 @@ function onCanvasDrag( 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 ) { From e1bb9814a2004331ba22e4dfea249df562a86a23 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 29 Jun 2018 10:29:08 -0700 Subject: [PATCH 08/13] Changelog for #1484. --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index fae18ba3..6f20568f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -16,6 +16,7 @@ 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) 2.3.1: From 890d9bc5994808bfe2b98a061da0b4ecda7f1683 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 29 Jun 2018 10:37:27 -0700 Subject: [PATCH 09/13] Changelog for #1416. --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 6f20568f..e2eceb7a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -17,6 +17,8 @@ OPENSEADRAGON CHANGELOG * 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) 2.3.1: From 452e50c8d8780ecb2c866282ec1b819f076a0370 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 3 Jul 2018 09:40:10 -0700 Subject: [PATCH 10/13] Making the DziTileSource honor minLevel. --- src/dzitilesource.js | 4 ++++ src/tiledimage.js | 1 + 2 files changed, 5 insertions(+) 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/tiledimage.js b/src/tiledimage.js index 6fb68413..563dfc89 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); lowestLevel = Math.min(lowestLevel, highestLevel); return { lowestLevel: lowestLevel, From 071b8657651a0585b260b64aa356ca63c816463f Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 6 Jul 2018 13:17:46 -0700 Subject: [PATCH 11/13] Tweaks to minLevel DZI patch --- changelog.txt | 3 ++- src/tiledimage.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index e2eceb7a..302b3702 100644 --- a/changelog.txt +++ b/changelog.txt @@ -19,7 +19,8 @@ OPENSEADRAGON CHANGELOG * 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/src/tiledimage.js b/src/tiledimage.js index 563dfc89..52012071 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -972,7 +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); + highestLevel = Math.max(highestLevel, this.source.minLevel || 0); lowestLevel = Math.min(lowestLevel, highestLevel); return { lowestLevel: lowestLevel, From 446af4dc94fada4bed502d45f4fa1d6d3dca1e56 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 20 Jul 2018 09:43:13 -0700 Subject: [PATCH 12/13] Version 2.4.0 --- changelog.txt | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 302b3702..d7423941 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,7 @@ OPENSEADRAGON CHANGELOG ======================= -2.4.0: (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) 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", From 1cdda569d5ad5541f85c39cc94a8f3e61ba80f05 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 20 Jul 2018 09:47:45 -0700 Subject: [PATCH 13/13] Started 2.4.1 --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index d7423941..e935148a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,8 @@ OPENSEADRAGON CHANGELOG ======================= +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)