Fix the viewport bounds for fitBoundsWithConstraints

This commit is contained in:
nein09 2015-02-08 22:46:55 -08:00
parent ed0ffb14cf
commit 449e80bf24

View File

@ -362,20 +362,19 @@
viewer.open(DZI_PATH); viewer.open(DZI_PATH);
}); });
var testRectsOutsideImage = [ var testRectsFitBounds = [
new OpenSeadragon.Rect(0, 0, 2000, 100), new OpenSeadragon.Rect(0, -0.75, 0.5, 1),
new OpenSeadragon.Rect(0, 0, 2000, 100), new OpenSeadragon.Rect(0.5, 0, 0.5, 0.8),
new OpenSeadragon.Rect(800, 800, 300, 300), new OpenSeadragon.Rect(0.75, 0.75, 0.5, 0.5),
new OpenSeadragon.Rect(-40, -40, 500, 500) new OpenSeadragon.Rect(-0.3, -0.3, 0.5, 0.5)
]; ];
// Why is it always this!? var expectedRectsFitBounds = [
var expectedRectFitBounds = new OpenSeadragon.Rect( new OpenSeadragon.Rect(-0.25, -0.5, 1, 1),
-0.05555555555555558, new OpenSeadragon.Rect(0.35, 0, 0.8, 0.8),
-0.05555555555555558, new OpenSeadragon.Rect(0.75, 0.75, 0.5, 0.5),
1.1111111111111112, new OpenSeadragon.Rect(-0.25, -0.25, 0.5, 0.5)
1.1111111111111112 ];
);
asyncTest('fitBoundsWithConstraints', function(){ asyncTest('fitBoundsWithConstraints', function(){
var openHandler = function(event) { var openHandler = function(event) {
@ -383,14 +382,14 @@
var viewport = viewer.viewport; var viewport = viewer.viewport;
viewport.zoomTo(ZOOM_FACTOR, null, true); viewport.zoomTo(ZOOM_FACTOR, null, true);
viewport.update(); viewport.update();
for(var i = 0; i < testRectsOutsideImage.length; i++){ for(var i = 0; i < testRectsFitBounds.length; i++){
var rect = testRectsOutsideImage[i]; var rect = testRectsFitBounds[i];
viewport.fitBoundsWithConstraints(rect, true); viewport.fitBoundsWithConstraints(rect, true);
viewport.update(); viewport.update();
propEqual( propEqual(
viewport.getBounds(), viewport.getBounds(),
expectedRectFitBounds, expectedRectsFitBounds[i],
"Fit bounds correctly." "Fit bounds correctly."
); );
} }