From a77ffd113341ffb25fa0c243126a7651a1d6619f Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 1 Aug 2017 13:11:09 -0700 Subject: [PATCH 01/13] Changelog for #1271 --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 980d78a1..531af964 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,8 @@ OPENSEADRAGON CHANGELOG 2.3.1: (In Progress) +* Debug mode now uses different colors for different tiled images (customizable via debugGridColor) (#1271) + 2.3.0: * BREAKING CHANGE: Tile.distance has been removed (#1027) From 49ee98bbb05f9a3749bd6a61e6bdf640036ec40d Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 3 Aug 2017 10:47:35 -0700 Subject: [PATCH 02/13] Fixed a problem with preventDefaultAction for the canvas-drag event --- changelog.txt | 1 + src/viewer.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 531af964..7a04e821 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ OPENSEADRAGON CHANGELOG 2.3.1: (In Progress) * Debug mode now uses different colors for different tiled images (customizable via debugGridColor) (#1271) +* Fixed a problem with preventDefaultAction for the canvas-drag event () 2.3.0: diff --git a/src/viewer.js b/src/viewer.js index 649456de..0921eca8 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -2655,6 +2655,7 @@ function onCanvasDrag( event ) { originalEvent: event.originalEvent, preventDefaultAction: event.preventDefaultAction }; + /** * Raised when a mouse or touch drag operation occurs on the {@link OpenSeadragon.Viewer#canvas} element. * @@ -2674,7 +2675,7 @@ function onCanvasDrag( event ) { */ this.raiseEvent( 'canvas-drag', canvasDragEventArgs); - if ( !event.preventDefaultAction && this.viewport ) { + if ( !canvasDragEventArgs.preventDefaultAction && this.viewport ) { gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); if( !this.panHorizontal ){ event.delta.x = 0; From db79a6af1e8c5b89a346ab1bab7c762505c187dd Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 3 Aug 2017 10:49:52 -0700 Subject: [PATCH 03/13] Changelog for #1278 --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 7a04e821..9ed55689 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,7 +4,7 @@ OPENSEADRAGON CHANGELOG 2.3.1: (In Progress) * Debug mode now uses different colors for different tiled images (customizable via debugGridColor) (#1271) -* Fixed a problem with preventDefaultAction for the canvas-drag event () +* Fixed a problem with preventDefaultAction for the canvas-drag event (#1278) 2.3.0: From cd4c4d38ed6938339beb623e34e80aea30a2373c Mon Sep 17 00:00:00 2001 From: Antoine Vandecreme Date: Sun, 6 Aug 2017 15:00:50 +0200 Subject: [PATCH 04/13] Fix getTileAtPoint floating point computation error --- src/tilesource.js | 3 ++- test/modules/tilesource.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/tilesource.js b/src/tilesource.js index b40598ae..84aa5a82 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -360,7 +360,8 @@ $.TileSource.prototype = { if (point.x >= 1) { x = this.getNumTiles(level).x - 1; } - if (point.y >= 1 / this.aspectRatio) { + var EPSILON = 1e-16; + if (point.y >= 1 / this.aspectRatio - EPSILON) { y = this.getNumTiles(level).y - 1; } diff --git a/test/modules/tilesource.js b/test/modules/tilesource.js index 21a9f30c..bac637c8 100644 --- a/test/modules/tilesource.js +++ b/test/modules/tilesource.js @@ -96,6 +96,17 @@ maxLevel: 0, }); assertTileAtPoint(0, new OpenSeadragon.Point(1, 1009 / 1006), new OpenSeadragon.Point(0, 0)); + + // Test for issue #1276 + tileSource = new OpenSeadragon.TileSource({ + width: 4036, + height: 1239, + tileWidth: 4036, + tileHeight: 1239, + tileOverlap: 0, + maxLevel: 0, + }); + assertTileAtPoint(0, new OpenSeadragon.Point(1, 1239 / 4036), new OpenSeadragon.Point(0, 0)); }); }()); From 7f5a18e46a500d2ef4a498a5be65d6df599d28a5 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 7 Aug 2017 10:54:02 -0700 Subject: [PATCH 05/13] Changelog for #1280 --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index 9ed55689..bbf01755 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ OPENSEADRAGON CHANGELOG * Debug mode now uses different colors for different tiled images (customizable via debugGridColor) (#1271) * Fixed a problem with preventDefaultAction for the canvas-drag event (#1278) +* Fixed an issue causing double images with certain aspect ratios (#1280) 2.3.0: From 8a4ef0cc2e0d149c724f6b2f10c66fe7777cb5d1 Mon Sep 17 00:00:00 2001 From: Mutlu Koesem Date: Wed, 9 Aug 2017 11:39:17 +0200 Subject: [PATCH 06/13] Fix placeholderFillStyle on tiledImage has no effect --- src/tiledimage.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/tiledimage.js b/src/tiledimage.js index 8851a933..b9c83838 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1805,15 +1805,19 @@ function compareTiles( previousBest, tile ) { * @param {OpenSeadragon.Tile[]} lastDrawn - An unordered list of Tiles drawn last frame. */ function drawTiles( tiledImage, lastDrawn ) { - if (tiledImage.opacity === 0 || lastDrawn.length === 0) { + if (tiledImage.opacity === 0 || (lastDrawn.length === 0 && !tiledImage.placeholderFillStyle)) { return; } - var tile = lastDrawn[0]; - var useSketch = tiledImage.opacity < 1 || - (tiledImage.compositeOperation && - tiledImage.compositeOperation !== 'source-over') || - (!tiledImage._isBottomItem() && tile._hasTransparencyChannel()); + var tile = lastDrawn[0]; + var useSketch; + + if (tile) { + useSketch = tiledImage.opacity < 1 || + (tiledImage.compositeOperation && + tiledImage.compositeOperation !== 'source-over') || + (!tiledImage._isBottomItem() && tile._hasTransparencyChannel()); + } var sketchScale; var sketchTranslate; From 36dd37b931af48ba7b37b5ce639d84a07eea96da Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 10 Aug 2017 10:39:02 -0700 Subject: [PATCH 07/13] Changelog for #1286 --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index bbf01755..a040417c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,7 @@ OPENSEADRAGON CHANGELOG * Debug mode now uses different colors for different tiled images (customizable via debugGridColor) (#1271) * Fixed a problem with preventDefaultAction for the canvas-drag event (#1278) * Fixed an issue causing double images with certain aspect ratios (#1280) +* Fixed: placeholderFillStyle had no effect (#1286) 2.3.0: From d1ea179296f269a22fb0fab4f7f8aff2bb150991 Mon Sep 17 00:00:00 2001 From: Oeystein Lygre Date: Mon, 21 Aug 2017 22:38:44 +0200 Subject: [PATCH 08/13] manage preventDefaultAction flag in canvas-double-click viewer event Trigger the canvas-double-click event before default double tap to zoom happens on the viewer --- src/viewer.js | 37 ++++++++++++--------- test/modules/events.js | 73 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 16 deletions(-) diff --git a/src/viewer.js b/src/viewer.js index 0921eca8..dc1d7438 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -2611,16 +2611,14 @@ function onCanvasClick( event ) { function onCanvasDblClick( event ) { var gestureSettings; - if ( !event.preventDefaultAction && this.viewport ) { - gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); - if ( gestureSettings.dblClickToZoom ) { - this.viewport.zoomBy( - event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick, - this.viewport.pointFromPixel( event.position, true ) - ); - this.viewport.applyConstraints(); - } - } + var canvasDblClickEventArgs = { + tracker: event.eventSource, + position: event.position, + shift: event.shift, + originalEvent: event.originalEvent, + preventDefaultAction: event.preventDefaultAction + }; + /** * Raised when a double mouse press/release or touch/remove occurs on the {@link OpenSeadragon.Viewer#canvas} element. * @@ -2632,14 +2630,21 @@ function onCanvasDblClick( event ) { * @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element. * @property {Boolean} shift - True if the shift key was pressed during this event. * @property {Object} originalEvent - The original DOM event. + * @property {Boolean} preventDefaultAction - Set to true to prevent default double tap to zoom behaviour. Default: false. * @property {?Object} userData - Arbitrary subscriber-defined object. */ - this.raiseEvent( 'canvas-double-click', { - tracker: event.eventSource, - position: event.position, - shift: event.shift, - originalEvent: event.originalEvent - }); + this.raiseEvent( 'canvas-double-click', canvasDblClickEventArgs); + + if ( !canvasDblClickEventArgs.preventDefaultAction && this.viewport ) { + gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); + if ( gestureSettings.dblClickToZoom ) { + this.viewport.zoomBy( + event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick, + this.viewport.pointFromPixel( event.position, true ) + ); + this.viewport.applyConstraints(); + } + } } function onCanvasDrag( event ) { diff --git a/test/modules/events.js b/test/modules/events.js index 7e681d05..af226a44 100644 --- a/test/modules/events.js +++ b/test/modules/events.js @@ -833,6 +833,79 @@ viewer.open('/test/data/testpattern.dzi'); }); + // ---------- + asyncTest('Viewer: preventDefaultAction in dblClickHandler', function() { + var tracker = viewer.innerTracker; + var epsilon = 0.0000001; + + function simulateDblTap() { + var touches = []; + TouchUtil.reset(); + + touches.push(TouchUtil.start([0,0])); + TouchUtil.end( touches[0] ); + touches.push(TouchUtil.start([0,0])); + TouchUtil.end( touches[1] ); + } + + var onOpen = function() { + viewer.removeHandler('open', onOpen); + + var originalZoom = viewer.viewport.getZoom(); + + var origDblClickHandler = tracker.dblClickHandler; + tracker.dblClickHandler = function(event) { + event.preventDefaultAction = true; + return origDblClickHandler(event); + }; + + TouchUtil.initTracker(tracker); + simulateDblTap(); + + var zoom = viewer.viewport.getZoom(); + Util.assessNumericValue(originalZoom, zoom, epsilon, + "Zoom on double tap should be prevented"); + + // Reset event handler to original + tracker.dblClickHandler = origDblClickHandler; + + simulateDblTap(); + originalZoom = originalZoom * viewer.zoomPerClick; + + var zoom = viewer.viewport.getZoom(); + Util.assessNumericValue(originalZoom, zoom, epsilon, + "Zoom on double tap should not be prevented"); + + + var dblClickHandler = function(event) { + event.preventDefaultAction = true; + } + + viewer.addHandler('canvas-double-click', dblClickHandler); + + var zoom = viewer.viewport.getZoom(); + Util.assessNumericValue(originalZoom, zoom, epsilon, + "Zoom on double tap should be prevented"); + + // Remove custom event handler + viewer.removeHandler('canvas-double-click', dblClickHandler); + + simulateDblTap(); + originalZoom = originalZoom * viewer.zoomPerClick; + + var zoom = viewer.viewport.getZoom(); + Util.assessNumericValue(originalZoom, zoom, epsilon, + "Zoom on double tap should not be prevented"); + + TouchUtil.resetTracker(tracker); + viewer.close(); + start(); + }; + + viewer.addHandler('open', onOpen); + viewer.open('/test/data/testpattern.dzi'); + }); + // ---------- asyncTest( 'EventSource/MouseTracker/Viewer: event.originalEvent event.userData canvas-drag canvas-drag-end canvas-release canvas-click', function () { var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ), From a49bbbcb06c390eead819acce941487ca7713f73 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 8 Sep 2017 14:03:40 -0700 Subject: [PATCH 09/13] Addressing seams that appear in wrap mode on Safari and Firefox --- src/tile.js | 15 +++++++++++++++ src/tiledimage.js | 20 +++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/tile.js b/src/tile.js index 61ba2e64..a0b29f4f 100644 --- a/src/tile.js +++ b/src/tile.js @@ -199,12 +199,27 @@ $.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, aja * @memberof OpenSeadragon.Tile# */ this.beingDrawn = false; + /** * Timestamp the tile was last touched. * @member {Number} lastTouchTime * @memberof OpenSeadragon.Tile# */ this.lastTouchTime = 0; + + /** + * Whether this tile is in the right-most column for its level. + * @member {Boolean} isRightMost + * @memberof OpenSeadragon.Tile# + */ + this.isRightMost = false; + + /** + * Whether this tile is in the bottom-most row for its level. + * @member {Boolean} isBottomMost + * @memberof OpenSeadragon.Tile# + */ + this.isBottomMost = false; }; /** @lends OpenSeadragon.Tile.prototype */ diff --git a/src/tiledimage.js b/src/tiledimage.js index b9c83838..a289026a 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1405,7 +1405,7 @@ function getTile( bounds.x += ( x - xMod ) / numTiles.x; bounds.y += (worldHeight / worldWidth) * (( y - yMod ) / numTiles.y); - tilesMatrix[ level ][ x ][ y ] = new $.Tile( + tile = new $.Tile( level, x, y, @@ -1416,6 +1416,16 @@ function getTile( tiledImage.loadTilesWithAjax, ajaxHeaders ); + + if (xMod === numTiles.x - 1) { + tile.isRightMost = true; + } + + if (yMod === numTiles.y - 1) { + tile.isBottomMost = true; + } + + tilesMatrix[ level ][ x ][ y ] = tile; } tile = tilesMatrix[ level ][ x ][ y ]; @@ -1602,6 +1612,14 @@ function positionTile( tile, overlap, viewport, viewportCenter, levelVisibility, sizeC = sizeC.plus( new $.Point( 1, 1 ) ); } + if (tile.isRightMost && tiledImage.wrapHorizontal) { + sizeC.x += 0.75; // Otherwise Firefox and Safari show seams + } + + if (tile.isBottomMost && tiledImage.wrapVertical) { + sizeC.y += 0.75; // Otherwise Firefox and Safari show seams + } + tile.position = positionC; tile.size = sizeC; tile.squaredDistance = tileSquaredDistance; From d13781baf9cbd21547a20017fdc0f2ab7627fb35 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 19 Sep 2017 09:52:09 -0700 Subject: [PATCH 10/13] Changelog for #1305 --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index a040417c..93758c63 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,7 @@ OPENSEADRAGON CHANGELOG * Fixed a problem with preventDefaultAction for the canvas-drag event (#1278) * Fixed an issue causing double images with certain aspect ratios (#1280) * Fixed: placeholderFillStyle had no effect (#1286) +* Fixed seams that appear in wrap mode on Safari and Firefox (#1305) 2.3.0: From 08414cdada7e577deeea905c9fd139bcfb69f8b7 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 19 Sep 2017 09:54:38 -0700 Subject: [PATCH 11/13] Version 2.3.1 --- changelog.txt | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 93758c63..57e7a76a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,7 @@ OPENSEADRAGON CHANGELOG ======================= -2.3.1: (In Progress) +2.3.1: * Debug mode now uses different colors for different tiled images (customizable via debugGridColor) (#1271) * Fixed a problem with preventDefaultAction for the canvas-drag event (#1278) diff --git a/package.json b/package.json index 231c5158..457edf01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openseadragon", - "version": "2.3.0", + "version": "2.3.1", "description": "Provides a smooth, zoomable user interface for HTML/Javascript.", "keywords": ["image", "zoom", "pan", "openseadragon", "seadragon", "deepzoom", "dzi", "iiif", "osm", "tms"], "homepage": "http://openseadragon.github.io/", From 365b3ee8bada9e8bbb4fd41c09ac374468db717a Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 19 Sep 2017 09:58:14 -0700 Subject: [PATCH 12/13] In progress for 2.4.0 --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 57e7a76a..64d7e821 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,8 @@ OPENSEADRAGON CHANGELOG ======================= +2.4.0: (In Progress) + 2.3.1: * Debug mode now uses different colors for different tiled images (customizable via debugGridColor) (#1271) From f471040ddfb5f03beb684cb58eea2ca6f6763883 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 19 Sep 2017 10:13:21 -0700 Subject: [PATCH 13/13] Changelog for #1288 --- changelog.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.txt b/changelog.txt index 64d7e821..9b8ac00b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,9 @@ OPENSEADRAGON CHANGELOG 2.4.0: (In Progress) +* BREAKING CHANGE: Viewer's canvas-double-click event is now fired before it initiates the zoom (#1288) +* You can now prevent canvas-double-click events from zooming on a per-event basis (#1288) + 2.3.1: * Debug mode now uses different colors for different tiled images (customizable via debugGridColor) (#1271)