Merge pull request #840 from avandecreme/rotation

Fix navigator not rotated when viewport rotation set in constructor.
This commit is contained in:
Ian Gilman 2016-02-10 09:48:13 -08:00
commit 0fbc71ef49
2 changed files with 63 additions and 3 deletions

View File

@ -199,11 +199,18 @@ $.Navigator = function( options ){
this.displayRegionContainer.appendChild(this.displayRegion); this.displayRegionContainer.appendChild(this.displayRegion);
this.element.getElementsByTagName('div')[0].appendChild(this.displayRegionContainer); this.element.getElementsByTagName('div')[0].appendChild(this.displayRegionContainer);
function rotate(degrees) {
_setTransformRotate(_this.displayRegionContainer, degrees);
_setTransformRotate(_this.displayRegion, -degrees);
_this.viewport.setRotation(degrees);
}
if (options.navigatorRotate) { if (options.navigatorRotate) {
var degrees = options.viewer.viewport ?
options.viewer.viewport.getRotation() :
options.viewer.degrees || 0;
rotate(degrees);
options.viewer.addHandler("rotate", function (args) { options.viewer.addHandler("rotate", function (args) {
_setTransformRotate(_this.displayRegionContainer, args.degrees); rotate(args.degrees);
_setTransformRotate(_this.displayRegion, -args.degrees);
_this.viewport.setRotation(args.degrees);
}); });
} }

View File

@ -867,4 +867,57 @@
}); });
asyncTest('Viewer rotation applied to navigator by default', function() {
viewer = OpenSeadragon({
id: 'example',
prefixUrl: '/build/openseadragon/images/',
tileSources: '/test/data/tall.dzi',
springStiffness: 100, // Faster animation = faster tests
showNavigator: true,
degrees: 45
});
viewer.addHandler('open', function openHandler() {
viewer.removeHandler('open', openHandler);
var navigator = viewer.navigator;
equal(navigator.viewport.getRotation(), 45,
"Rotation set in constructor should be applied to navigator by default.");
viewer.viewport.setRotation(90);
equal(navigator.viewport.getRotation(), 90,
"Rotation set by setRotation should be applied to navigator by default.");
start();
});
});
asyncTest('Viewer rotation not applied to navigator when navigatorRotate=false', function() {
viewer = OpenSeadragon({
id: 'example',
prefixUrl: '/build/openseadragon/images/',
tileSources: '/test/data/tall.dzi',
springStiffness: 100, // Faster animation = faster tests
showNavigator: true,
degrees: 45,
navigatorRotate: false
});
viewer.addHandler('open', function openHandler() {
viewer.removeHandler('open', openHandler);
var navigator = viewer.navigator;
equal(navigator.viewport.getRotation(), 0,
"Rotation set in constructor should not be applied to navigator when navigatorRotate is false.");
viewer.viewport.setRotation(90);
equal(navigator.viewport.getRotation(), 0,
"Rotation set by setRotation should not be applied to navigator when navigatorRotate is false.");
start();
});
});
})(); })();