From 033b650c29c7da7d8871e620d2304ec83e433fe7 Mon Sep 17 00:00:00 2001 From: A Date: Thu, 26 May 2016 13:24:03 -0400 Subject: [PATCH 1/9] Fix #946 Fix for https://github.com/openseadragon/openseadragon/issues/946 --- src/viewer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/viewer.js b/src/viewer.js index 6ed18bc0..d64bda51 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1397,6 +1397,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, if (_this.navigator) { optionsClone = $.extend({}, queueItem.options, { + replace: false, // navigator already removed the layer, nothing to replace originalTiledImage: tiledImage, tileSource: queueItem.tileSource }); From 0043c8a6cea9826c6d1d0db1b8369e94301e6786 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 26 May 2016 11:54:50 -0700 Subject: [PATCH 2/9] Changelog for #948 --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index 725bfdc0..587ea898 100644 --- a/changelog.txt +++ b/changelog.txt @@ -47,6 +47,7 @@ OPENSEADRAGON CHANGELOG * Fixed an issue with simultaneous touch events (#930) * Avoid loading clipped out tiles (#939) * Improved precision for subtle moves with fitBounds (#939) +* Fixed an issue in viewer.addTiledImage with replace:true when viewer has navigator (#948) 2.1.0: From 373e61e0dfbdd6753ad4ce5f319f8156c322b71b Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 26 May 2016 15:14:19 -0700 Subject: [PATCH 3/9] Version bump to 2.2.0 --- changelog.txt | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 587ea898..ec976b6b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,7 @@ OPENSEADRAGON CHANGELOG ======================= -2.2.0: (in progress) +2.2.0: * BREAKING CHANGE: Viewport.homeBounds, Viewport.contentSize, Viewport.contentAspectX and Viewport.contentAspectY have been removed. (#846) diff --git a/package.json b/package.json index 7da958cc..245288c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openseadragon", - "version": "2.1.0", + "version": "2.2.0", "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 a81f3a9b31597201222ca89cd3e2673060a7e90d Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 26 May 2016 15:19:14 -0700 Subject: [PATCH 4/9] Started 2.2.1 "in progress" for changelog --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index ec976b6b..9ab9539d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,8 @@ OPENSEADRAGON CHANGELOG ======================= +2.2.1: (in progress) + 2.2.0: * BREAKING CHANGE: Viewport.homeBounds, Viewport.contentSize, Viewport.contentAspectX and From 755d8f01d02ebd69b318832c62ea771870c4664c Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 26 May 2016 16:00:04 -0700 Subject: [PATCH 5/9] Attempting to fix Gitter badge for npm --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8564916..92b6fb86 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # OpenSeadragon -[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/openseadragon/openseadragon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://secure.travis-ci.org/openseadragon/openseadragon.png?branch=master)](http://travis-ci.org/openseadragon/openseadragon) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/openseadragon/openseadragon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://secure.travis-ci.org/openseadragon/openseadragon.png?branch=master)](http://travis-ci.org/openseadragon/openseadragon) An open-source, web-based viewer for zoomable images, implemented in pure JavaScript. From 0035b3f36ff9a526a4d17298f45a224fd5f421c3 Mon Sep 17 00:00:00 2001 From: Victor Rodriguez Gil Date: Mon, 13 Jun 2016 23:04:55 +0000 Subject: [PATCH 6/9] Test that shows the bug #890, fails --- test/modules/viewport.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/modules/viewport.js b/test/modules/viewport.js index f39473cf..fb94d11d 100644 --- a/test/modules/viewport.js +++ b/test/modules/viewport.js @@ -437,8 +437,8 @@ viewport.applyConstraints(true); var bounds = viewport.getBounds(); Util.assertRectangleEquals( - bounds, new OpenSeadragon.Rect(0.7, 0.7, 1, 1), + bounds, EPSILON, "Viewport.applyConstraints should move viewport."); start(); @@ -447,6 +447,27 @@ viewer.open(DZI_PATH); }); + asyncTest('applyConstraints with visibilityRatio = 1 shouldn\'t bounce around', function() { + var openHandler = function() { + viewer.removeHandler('open', openHandler); + var viewport = viewer.viewport; + + viewport.visibilityRatio = 1; + viewport.zoomTo(0.5, undefined, true); + viewport.panBy(new OpenSeadragon.Point(0.75, 0), true); + viewport.applyConstraints(true); + var bounds = viewport.getBounds(); + Util.assertRectangleEquals( + new OpenSeadragon.Rect(-0.5, 1, 2, 2), + bounds, + EPSILON, + "Viewport.applyConstraints should move viewport to the center, not to a side."); + start(); + }; + viewer.addHandler('open', openHandler); + viewer.open(TALL_PATH); + }); + asyncTest('applyConstraints with rotation', function() { var openHandler = function() { viewer.removeHandler('open', openHandler); From c91039b5459d8c01bf233015db5261aec2c022ff Mon Sep 17 00:00:00 2001 From: Victor Rodriguez Gil Date: Mon, 13 Jun 2016 23:07:17 +0000 Subject: [PATCH 7/9] Code that fixes #890, new test passes. Events.js test needed fixing with good value, unrelated to actual test. --- src/viewport.js | 43 ++++++++++++++++++++++++++---------------- test/modules/events.js | 2 +- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/viewport.js b/src/viewport.js index da2ce761..60a5e2c4 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -503,21 +503,26 @@ $.Viewport.prototype = { } else { var dx = 0; var thresholdLeft = newBounds.x + (newBounds.width - horizontalThreshold); - if (this._contentBoundsNoRotate.x > thresholdLeft) { - dx = this._contentBoundsNoRotate.x - thresholdLeft; - } - + var leftDx = this._contentBoundsNoRotate.x - thresholdLeft; var contentRight = this._contentBoundsNoRotate.x + this._contentBoundsNoRotate.width; var thresholdRight = newBounds.x + horizontalThreshold; + var rightDx = contentRight - thresholdRight; + + if (this._contentBoundsNoRotate.x > thresholdLeft) { + dx = leftDx; + } if (contentRight < thresholdRight) { - var newDx = contentRight - thresholdRight; if (dx) { - dx = (dx + newDx) / 2; + dx = (dx + rightDx) / 2; } else { - dx = newDx; + dx = rightDx; } } - newBounds.x += dx; + if (horizontalThreshold > this._contentBoundsNoRotate.width && (newBounds.x > -thresholdLeft || newBounds.x + horizontalThreshold < 1)) { + newBounds.x += (leftDx + rightDx) / 2; + } else { + newBounds.x += dx; + } } if (this.wrapVertical) { @@ -525,21 +530,27 @@ $.Viewport.prototype = { } else { var dy = 0; var thresholdTop = newBounds.y + (newBounds.height - verticalThreshold); - if (this._contentBoundsNoRotate.y > thresholdTop) { - dy = this._contentBoundsNoRotate.y - thresholdTop; - } - + var topDy = this._contentBoundsNoRotate.y - thresholdTop; var contentBottom = this._contentBoundsNoRotate.y + this._contentBoundsNoRotate.height; var thresholdBottom = newBounds.y + verticalThreshold; + var bottomDy = contentBottom - thresholdBottom; + + if (this._contentBoundsNoRotate.y > thresholdTop) { + dy = topDy; + } if (contentBottom < thresholdBottom) { - var newDy = contentBottom - thresholdBottom; if (dy) { - dy = (dy + newDy) / 2; + dy = (dy + bottomDy) / 2; } else { - dy = newDy; + dy = bottomDy; } } - newBounds.y += dy; + if (verticalThreshold > this._contentBoundsNoRotate.height && (newBounds.y > -thresholdTop || newBounds.y + verticalThreshold < 1)) { + newBounds.y += (topDy + bottomDy) / 2; + } else { + newBounds.y += dy; + } + } if (this.viewer) { diff --git a/test/modules/events.js b/test/modules/events.js index 30dc28a2..ccfbab26 100644 --- a/test/modules/events.js +++ b/test/modules/events.js @@ -820,8 +820,8 @@ Util.assessNumericValue(zoom, 0.002, epsilon, "Zoom should not be prevented"); Util.assertRectangleEquals( + new OpenSeadragon.Rect(-249.5, -0.25, 500, 0.5), bounds, - new OpenSeadragon.Rect(-250, -0.25, 500, 0.5), epsilon, 'Pan should not be prevented'); From 36264c44ef56484cae8e2ae072d04cf67bc29b00 Mon Sep 17 00:00:00 2001 From: Victor Rodriguez Gil Date: Tue, 14 Jun 2016 17:31:21 +0000 Subject: [PATCH 8/9] simplified constraint code --- src/viewport.js | 58 +++++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/src/viewport.js b/src/viewport.js index 60a5e2c4..2ac499d4 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -495,62 +495,40 @@ $.Viewport.prototype = { bounds.width, bounds.height); - var horizontalThreshold = this.visibilityRatio * newBounds.width; - var verticalThreshold = this.visibilityRatio * newBounds.height; - if (this.wrapHorizontal) { //do nothing } else { - var dx = 0; - var thresholdLeft = newBounds.x + (newBounds.width - horizontalThreshold); - var leftDx = this._contentBoundsNoRotate.x - thresholdLeft; + var horizontalThreshold = this.visibilityRatio * newBounds.width; + var boundsRight = newBounds.x + newBounds.width; var contentRight = this._contentBoundsNoRotate.x + this._contentBoundsNoRotate.width; - var thresholdRight = newBounds.x + horizontalThreshold; - var rightDx = contentRight - thresholdRight; + var leftDx = this._contentBoundsNoRotate.x - boundsRight + horizontalThreshold; + var rightDx = contentRight - newBounds.x - horizontalThreshold; - if (this._contentBoundsNoRotate.x > thresholdLeft) { - dx = leftDx; - } - if (contentRight < thresholdRight) { - if (dx) { - dx = (dx + rightDx) / 2; - } else { - dx = rightDx; - } - } - if (horizontalThreshold > this._contentBoundsNoRotate.width && (newBounds.x > -thresholdLeft || newBounds.x + horizontalThreshold < 1)) { + if (horizontalThreshold > this._contentBoundsNoRotate.width) { newBounds.x += (leftDx + rightDx) / 2; - } else { - newBounds.x += dx; + } else if (rightDx < 0) { + newBounds.x += rightDx; + } else if (leftDx > 0) { + newBounds.x += leftDx; } } if (this.wrapVertical) { //do nothing } else { - var dy = 0; - var thresholdTop = newBounds.y + (newBounds.height - verticalThreshold); - var topDy = this._contentBoundsNoRotate.y - thresholdTop; + var verticalThreshold = this.visibilityRatio * newBounds.height; + var boundsBottom = newBounds.y + newBounds.height; var contentBottom = this._contentBoundsNoRotate.y + this._contentBoundsNoRotate.height; - var thresholdBottom = newBounds.y + verticalThreshold; - var bottomDy = contentBottom - thresholdBottom; + var topDy = this._contentBoundsNoRotate.y - boundsBottom + verticalThreshold; + var bottomDy = contentBottom - newBounds.y - verticalThreshold; - if (this._contentBoundsNoRotate.y > thresholdTop) { - dy = topDy; - } - if (contentBottom < thresholdBottom) { - if (dy) { - dy = (dy + bottomDy) / 2; - } else { - dy = bottomDy; - } - } - if (verticalThreshold > this._contentBoundsNoRotate.height && (newBounds.y > -thresholdTop || newBounds.y + verticalThreshold < 1)) { + if (verticalThreshold > this._contentBoundsNoRotate.height) { newBounds.y += (topDy + bottomDy) / 2; - } else { - newBounds.y += dy; + } else if (bottomDy < 0) { + newBounds.y += bottomDy; + } else if (topDy > 0) { + newBounds.y += topDy; } - } if (this.viewer) { From 18c90ed2e0ca6de78cbedb715cb940297f46c66b Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Wed, 15 Jun 2016 09:50:17 -0700 Subject: [PATCH 9/9] Changelog for #965 --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 9ab9539d..e63036f5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,8 @@ OPENSEADRAGON CHANGELOG 2.2.1: (in progress) +* Fixed problems with zoom/pan constraints with certain extreme settings (#965) + 2.2.0: * BREAKING CHANGE: Viewport.homeBounds, Viewport.contentSize, Viewport.contentAspectX and