This commit is contained in:
Ralph Krimmel 2016-06-17 08:26:34 +02:00
commit 7bf79eac77
7 changed files with 54 additions and 38 deletions

View File

@ -1,5 +1,5 @@
# OpenSeadragon # 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. An open-source, web-based viewer for zoomable images, implemented in pure JavaScript.

View File

@ -1,7 +1,11 @@
OPENSEADRAGON CHANGELOG OPENSEADRAGON CHANGELOG
======================= =======================
2.2.0: (in progress) 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 * BREAKING CHANGE: Viewport.homeBounds, Viewport.contentSize, Viewport.contentAspectX and
Viewport.contentAspectY have been removed. (#846) Viewport.contentAspectY have been removed. (#846)
@ -47,6 +51,7 @@ OPENSEADRAGON CHANGELOG
* Fixed an issue with simultaneous touch events (#930) * Fixed an issue with simultaneous touch events (#930)
* Avoid loading clipped out tiles (#939) * Avoid loading clipped out tiles (#939)
* Improved precision for subtle moves with fitBounds (#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: 2.1.0:

View File

@ -1,6 +1,6 @@
{ {
"name": "openseadragon", "name": "openseadragon",
"version": "2.1.0", "version": "2.2.0",
"description": "Provides a smooth, zoomable user interface for HTML/Javascript.", "description": "Provides a smooth, zoomable user interface for HTML/Javascript.",
"keywords": ["image", "zoom", "pan", "openseadragon", "seadragon", "deepzoom", "dzi", "iiif", "osm", "tms"], "keywords": ["image", "zoom", "pan", "openseadragon", "seadragon", "deepzoom", "dzi", "iiif", "osm", "tms"],
"homepage": "http://openseadragon.github.io/", "homepage": "http://openseadragon.github.io/",

View File

@ -1397,6 +1397,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
if (_this.navigator) { if (_this.navigator) {
optionsClone = $.extend({}, queueItem.options, { optionsClone = $.extend({}, queueItem.options, {
replace: false, // navigator already removed the layer, nothing to replace
originalTiledImage: tiledImage, originalTiledImage: tiledImage,
tileSource: queueItem.tileSource tileSource: queueItem.tileSource
}); });

View File

@ -495,51 +495,40 @@ $.Viewport.prototype = {
bounds.width, bounds.width,
bounds.height); bounds.height);
var horizontalThreshold = this.visibilityRatio * newBounds.width;
var verticalThreshold = this.visibilityRatio * newBounds.height;
if (this.wrapHorizontal) { if (this.wrapHorizontal) {
//do nothing //do nothing
} else { } else {
var dx = 0; var horizontalThreshold = this.visibilityRatio * newBounds.width;
var thresholdLeft = newBounds.x + (newBounds.width - horizontalThreshold); var boundsRight = newBounds.x + newBounds.width;
if (this._contentBoundsNoRotate.x > thresholdLeft) {
dx = this._contentBoundsNoRotate.x - thresholdLeft;
}
var contentRight = this._contentBoundsNoRotate.x + this._contentBoundsNoRotate.width; var contentRight = this._contentBoundsNoRotate.x + this._contentBoundsNoRotate.width;
var thresholdRight = newBounds.x + horizontalThreshold; var leftDx = this._contentBoundsNoRotate.x - boundsRight + horizontalThreshold;
if (contentRight < thresholdRight) { var rightDx = contentRight - newBounds.x - horizontalThreshold;
var newDx = contentRight - thresholdRight;
if (dx) { if (horizontalThreshold > this._contentBoundsNoRotate.width) {
dx = (dx + newDx) / 2; newBounds.x += (leftDx + rightDx) / 2;
} else { } else if (rightDx < 0) {
dx = newDx; newBounds.x += rightDx;
} } else if (leftDx > 0) {
newBounds.x += leftDx;
} }
newBounds.x += dx;
} }
if (this.wrapVertical) { if (this.wrapVertical) {
//do nothing //do nothing
} else { } else {
var dy = 0; var verticalThreshold = this.visibilityRatio * newBounds.height;
var thresholdTop = newBounds.y + (newBounds.height - verticalThreshold); var boundsBottom = newBounds.y + newBounds.height;
if (this._contentBoundsNoRotate.y > thresholdTop) {
dy = this._contentBoundsNoRotate.y - thresholdTop;
}
var contentBottom = this._contentBoundsNoRotate.y + this._contentBoundsNoRotate.height; var contentBottom = this._contentBoundsNoRotate.y + this._contentBoundsNoRotate.height;
var thresholdBottom = newBounds.y + verticalThreshold; var topDy = this._contentBoundsNoRotate.y - boundsBottom + verticalThreshold;
if (contentBottom < thresholdBottom) { var bottomDy = contentBottom - newBounds.y - verticalThreshold;
var newDy = contentBottom - thresholdBottom;
if (dy) { if (verticalThreshold > this._contentBoundsNoRotate.height) {
dy = (dy + newDy) / 2; newBounds.y += (topDy + bottomDy) / 2;
} else { } else if (bottomDy < 0) {
dy = newDy; newBounds.y += bottomDy;
} } else if (topDy > 0) {
newBounds.y += topDy;
} }
newBounds.y += dy;
} }
if (this.viewer) { if (this.viewer) {

View File

@ -820,8 +820,8 @@
Util.assessNumericValue(zoom, 0.002, epsilon, Util.assessNumericValue(zoom, 0.002, epsilon,
"Zoom should not be prevented"); "Zoom should not be prevented");
Util.assertRectangleEquals( Util.assertRectangleEquals(
new OpenSeadragon.Rect(-249.5, -0.25, 500, 0.5),
bounds, bounds,
new OpenSeadragon.Rect(-250, -0.25, 500, 0.5),
epsilon, epsilon,
'Pan should not be prevented'); 'Pan should not be prevented');

View File

@ -437,8 +437,8 @@
viewport.applyConstraints(true); viewport.applyConstraints(true);
var bounds = viewport.getBounds(); var bounds = viewport.getBounds();
Util.assertRectangleEquals( Util.assertRectangleEquals(
bounds,
new OpenSeadragon.Rect(0.7, 0.7, 1, 1), new OpenSeadragon.Rect(0.7, 0.7, 1, 1),
bounds,
EPSILON, EPSILON,
"Viewport.applyConstraints should move viewport."); "Viewport.applyConstraints should move viewport.");
start(); start();
@ -447,6 +447,27 @@
viewer.open(DZI_PATH); 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() { asyncTest('applyConstraints with rotation', function() {
var openHandler = function() { var openHandler = function() {
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);