diff --git a/src/drawer.js b/src/drawer.js index 0289019a..4485da98 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -500,7 +500,7 @@ $.Drawer.prototype = { if ( this.viewport.degrees !== 0 ) { this._offsetForRotation({degrees: this.viewport.degrees}); } - if (tiledImage.getRotation(true) !== 0) { + if (tiledImage.getRotation(true) % 360 !== 0) { this._offsetForRotation({ degrees: tiledImage.getRotation(true), point: tiledImage.viewport.pixelFromPointNoRotate( @@ -569,7 +569,7 @@ $.Drawer.prototype = { if ( this.viewport.degrees !== 0 ) { this._restoreRotationChanges(); } - if (tiledImage.getRotation(true) !== 0) { + if (tiledImage.getRotation(true) % 360 !== 0) { this._restoreRotationChanges(); } context.restore(); diff --git a/src/tiledimage.js b/src/tiledimage.js index c6cdd7ec..70859ec0 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -132,7 +132,7 @@ $.TiledImage = function( options ) { var fitBoundsPlacement = options.fitBoundsPlacement || OpenSeadragon.Placement.CENTER; delete options.fitBoundsPlacement; - var degrees = $.positiveModulo(options.degrees || 0, 360); + var degrees = options.degrees || 0; delete options.degrees; $.extend( true, this, { @@ -789,7 +789,6 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag * @fires OpenSeadragon.TiledImage.event:bounds-change */ setRotation: function(degrees, immediately) { - degrees = $.positiveModulo(degrees, 360); if (this._degreesSpring.target.value === degrees && this._degreesSpring.isAtTargetValue()) { return; @@ -1713,11 +1712,11 @@ function drawTiles( tiledImage, lastDrawn ) { var zoom = tiledImage.viewport.getZoom(true); var imageZoom = tiledImage.viewportToImageZoom(zoom); - // TODO: support tile edge smoothing with tiled image rotation. + if (lastDrawn.length > 1 && imageZoom > tiledImage.smoothTileEdgesMinZoom && !tiledImage.iOSDevice && - tiledImage.getRotation(true) === 0 && + tiledImage.getRotation(true) % 360 === 0 && // TODO: support tile edge smoothing with tiled image rotation. $.supportsCanvas) { // When zoomed in a lot (>100%) the tile edges are visible. // So we have to composite them at ~100% and scale them up together. @@ -1751,7 +1750,7 @@ function drawTiles( tiledImage, lastDrawn ) { useSketch: useSketch }); } - if (tiledImage.getRotation(true) !== 0) { + if (tiledImage.getRotation(true) % 360 !== 0) { tiledImage._drawer._offsetForRotation({ degrees: tiledImage.getRotation(true), point: tiledImage.viewport.pixelFromPointNoRotate( @@ -1828,7 +1827,7 @@ function drawTiles( tiledImage, lastDrawn ) { } if (!sketchScale) { - if (tiledImage.getRotation(true) !== 0) { + if (tiledImage.getRotation(true) % 360 !== 0) { tiledImage._drawer._restoreRotationChanges(useSketch); } if (tiledImage.viewport.degrees !== 0) { @@ -1844,7 +1843,7 @@ function drawTiles( tiledImage, lastDrawn ) { useSketch: false }); } - if (tiledImage.getRotation(true) !== 0) { + if (tiledImage.getRotation(true) % 360 !== 0) { tiledImage._drawer._offsetForRotation({ degrees: tiledImage.getRotation(true), point: tiledImage.viewport.pixelFromPointNoRotate( @@ -1861,7 +1860,7 @@ function drawTiles( tiledImage, lastDrawn ) { bounds: bounds }); if (sketchScale) { - if (tiledImage.getRotation(true) !== 0) { + if (tiledImage.getRotation(true) % 360 !== 0) { tiledImage._drawer._restoreRotationChanges(false); } if (tiledImage.viewport.degrees !== 0) { diff --git a/test/modules/tiledimage.js b/test/modules/tiledimage.js index 1b05b557..b2206341 100644 --- a/test/modules/tiledimage.js +++ b/test/modules/tiledimage.js @@ -319,10 +319,16 @@ function testDefaultRotation() { var image = viewer.world.getItemAt(0); - strictEqual(image.getRotation(), 0, 'image has default rotation'); + strictEqual(image.getRotation(true), 0, 'image has default current rotation'); + strictEqual(image.getRotation(false), 0, 'image has default target rotation'); image.setRotation(400); - strictEqual(image.getRotation(), 40, 'rotation is set correctly'); + strictEqual(image.getRotation(true), 0, 'current rotation is not changed'); + strictEqual(image.getRotation(false), 400, 'target rotation is set correctly'); + + image.setRotation(200, true); + strictEqual(image.getRotation(true), 200, 'current rotation is set correctly'); + strictEqual(image.getRotation(false), 200, 'target rotation is set correctly'); viewer.addOnceHandler('open', testTileSourceRotation); viewer.open({ @@ -333,7 +339,8 @@ function testTileSourceRotation() { var image = viewer.world.getItemAt(0); - strictEqual(image.getRotation(), 300, 'image has correct rotation'); + strictEqual(image.getRotation(true), -60, 'image has correct current rotation'); + strictEqual(image.getRotation(false), -60, 'image has correct target rotation'); start(); }