mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Merge pull request #840 from avandecreme/rotation
Fix navigator not rotated when viewport rotation set in constructor.
This commit is contained in:
commit
0fbc71ef49
@ -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);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user