Viewport and tiledImage test fixes

This commit is contained in:
Ian Gilman 2015-01-02 14:24:05 -08:00
parent a7d9f7dcd5
commit 56ee5bd3c5
3 changed files with 8 additions and 14 deletions

View File

@ -38,6 +38,7 @@ OPENSEADRAGON CHANGELOG
* Margins option to push the home region in from the edges of the Viewer (#505) * 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 * Rect and Point toString() functions are now consistent: rounding values to nearest hundredth
* Overlays appear in the DOM immediately on open or addOverlay (#507) * Overlays appear in the DOM immediately on open or addOverlay (#507)
* imageLoaderLimit now works (#544)
1.2.0: (in progress) 1.2.0: (in progress)

View File

@ -36,6 +36,7 @@
// dictionary from hash to private properties // dictionary from hash to private properties
var THIS = {}; var THIS = {};
var nextHash = 1;
/** /**
* *
@ -89,7 +90,7 @@ $.Viewer = function( options ) {
//internal state and dom identifiers //internal state and dom identifiers
id: options.id, id: options.id,
hash: options.hash || options.id, hash: options.hash || nextHash++,
//dom nodes //dom nodes
/** /**

View File

@ -3,7 +3,7 @@
(function () { (function () {
var viewer; var viewer;
var VIEWER_ID = "example"; var VIEWER_ID = "example";
var PREFIX_URL = "/build/openseadragon/images"; var PREFIX_URL = "/build/openseadragon/images/";
var SPRING_STIFFNESS = 100; // Faster animation = faster tests var SPRING_STIFFNESS = 100; // Faster animation = faster tests
module("viewport", { module("viewport", {
@ -425,9 +425,7 @@
return el.times(window_boundary); return el.times(window_boundary);
}, },
getExpected: function(orig, viewport) { getExpected: function(orig, viewport) {
var position, pos_point; var pos_point = OpenSeadragon.getElementOffset(viewer.element);
position = viewer.element.getBoundingClientRect();
pos_point = new OpenSeadragon.Point(position.top, position.left);
return orig.minus(pos_point).divide(viewport.getContainerSize().x * ZOOM_FACTOR).plus(VIEWER_PADDING); return orig.minus(pos_point).divide(viewport.getContainerSize().x * ZOOM_FACTOR).plus(VIEWER_PADDING);
}, },
method: 'windowToViewportCoordinates' method: 'windowToViewportCoordinates'
@ -441,9 +439,7 @@
return el.times(viewer.source.dimensions.x); return el.times(viewer.source.dimensions.x);
}, },
getExpected: function(orig, viewport) { getExpected: function(orig, viewport) {
var position, pos_point; var pos_point = OpenSeadragon.getElementOffset(viewer.element);
position = viewer.element.getBoundingClientRect();
pos_point = new OpenSeadragon.Point(position.top, position.left);
return orig.plus(pos_point).minus(VIEWER_PADDING.times(viewport.getContainerSize().x * ZOOM_FACTOR)); return orig.plus(pos_point).minus(VIEWER_PADDING.times(viewport.getContainerSize().x * ZOOM_FACTOR));
}, },
method: 'imageToWindowCoordinates' method: 'imageToWindowCoordinates'
@ -458,9 +454,7 @@
return el.times(window_boundary); return el.times(window_boundary);
}, },
getExpected: function(orig, viewport) { getExpected: function(orig, viewport) {
var position, pos_point; var pos_point = OpenSeadragon.getElementOffset(viewer.element);
position = viewer.element.getBoundingClientRect();
pos_point = new OpenSeadragon.Point(position.top, position.left);
return orig.minus(pos_point).divide(viewport.getContainerSize().x * ZOOM_FACTOR).plus(VIEWER_PADDING); return orig.minus(pos_point).divide(viewport.getContainerSize().x * ZOOM_FACTOR).plus(VIEWER_PADDING);
}, },
method: 'windowToViewportCoordinates' method: 'windowToViewportCoordinates'
@ -474,9 +468,7 @@
return el.times(viewer.source.dimensions.x); return el.times(viewer.source.dimensions.x);
}, },
getExpected: function(orig, viewport) { getExpected: function(orig, viewport) {
var position, pos_point; var pos_point = OpenSeadragon.getElementOffset(viewer.element);
position = viewer.element.getBoundingClientRect();
pos_point = new OpenSeadragon.Point(position.top, position.left);
return orig.minus(VIEWER_PADDING).times(viewport.getContainerSize().x * ZOOM_FACTOR).plus(pos_point); return orig.minus(VIEWER_PADDING).times(viewport.getContainerSize().x * ZOOM_FACTOR).plus(pos_point);
}, },
method: 'viewportToWindowCoordinates' method: 'viewportToWindowCoordinates'