From 56ee5bd3c5a561867e964056963ab9e269ccf4da Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 2 Jan 2015 14:24:05 -0800 Subject: [PATCH] Viewport and tiledImage test fixes --- changelog.txt | 1 + src/viewer.js | 3 ++- test/viewport.js | 18 +++++------------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/changelog.txt b/changelog.txt index 2f13e0ef..98a94fd0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -38,6 +38,7 @@ OPENSEADRAGON CHANGELOG * Margins option to push the home region in from the edges of the Viewer (#505) * Rect and Point toString() functions are now consistent: rounding values to nearest hundredth * Overlays appear in the DOM immediately on open or addOverlay (#507) +* imageLoaderLimit now works (#544) 1.2.0: (in progress) diff --git a/src/viewer.js b/src/viewer.js index e3964b3b..781af981 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -36,6 +36,7 @@ // dictionary from hash to private properties var THIS = {}; +var nextHash = 1; /** * @@ -89,7 +90,7 @@ $.Viewer = function( options ) { //internal state and dom identifiers id: options.id, - hash: options.hash || options.id, + hash: options.hash || nextHash++, //dom nodes /** diff --git a/test/viewport.js b/test/viewport.js index 769f934f..c0eaf94b 100644 --- a/test/viewport.js +++ b/test/viewport.js @@ -3,7 +3,7 @@ (function () { var viewer; var VIEWER_ID = "example"; - var PREFIX_URL = "/build/openseadragon/images"; + var PREFIX_URL = "/build/openseadragon/images/"; var SPRING_STIFFNESS = 100; // Faster animation = faster tests module("viewport", { @@ -425,9 +425,7 @@ return el.times(window_boundary); }, getExpected: function(orig, viewport) { - var position, pos_point; - position = viewer.element.getBoundingClientRect(); - pos_point = new OpenSeadragon.Point(position.top, position.left); + var pos_point = OpenSeadragon.getElementOffset(viewer.element); return orig.minus(pos_point).divide(viewport.getContainerSize().x * ZOOM_FACTOR).plus(VIEWER_PADDING); }, method: 'windowToViewportCoordinates' @@ -441,9 +439,7 @@ return el.times(viewer.source.dimensions.x); }, getExpected: function(orig, viewport) { - var position, pos_point; - position = viewer.element.getBoundingClientRect(); - pos_point = new OpenSeadragon.Point(position.top, position.left); + var pos_point = OpenSeadragon.getElementOffset(viewer.element); return orig.plus(pos_point).minus(VIEWER_PADDING.times(viewport.getContainerSize().x * ZOOM_FACTOR)); }, method: 'imageToWindowCoordinates' @@ -458,9 +454,7 @@ return el.times(window_boundary); }, getExpected: function(orig, viewport) { - var position, pos_point; - position = viewer.element.getBoundingClientRect(); - pos_point = new OpenSeadragon.Point(position.top, position.left); + var pos_point = OpenSeadragon.getElementOffset(viewer.element); return orig.minus(pos_point).divide(viewport.getContainerSize().x * ZOOM_FACTOR).plus(VIEWER_PADDING); }, method: 'windowToViewportCoordinates' @@ -474,9 +468,7 @@ return el.times(viewer.source.dimensions.x); }, getExpected: function(orig, viewport) { - var position, pos_point; - position = viewer.element.getBoundingClientRect(); - pos_point = new OpenSeadragon.Point(position.top, position.left); + var pos_point = OpenSeadragon.getElementOffset(viewer.element); return orig.minus(VIEWER_PADDING).times(viewport.getContainerSize().x * ZOOM_FACTOR).plus(pos_point); }, method: 'viewportToWindowCoordinates'