mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
reworked setRotation to allow all degree values
This commit is contained in:
parent
9bce0e696c
commit
5f50d9e59e
@ -917,16 +917,18 @@ $.Viewport.prototype = {
|
|||||||
if (immediately) {
|
if (immediately) {
|
||||||
this.degreesSpring.resetTo(degrees);
|
this.degreesSpring.resetTo(degrees);
|
||||||
} else {
|
} else {
|
||||||
var from = $.euclideanModulo(this.degreesSpring.current.value, 360);
|
var normalizedFrom = $.positiveModulo(this.degreesSpring.current.value, 360);
|
||||||
this.degreesSpring.resetTo(from);
|
var normalizedTo = $.positiveModulo(degrees, 360);
|
||||||
var to = $.euclideanModulo(degrees, 360);
|
var diff = normalizedTo - normalizedFrom;
|
||||||
var diff = to - from;
|
|
||||||
if (diff > 180) {
|
if (diff > 180) {
|
||||||
to -= 360;
|
normalizedTo -= 360;
|
||||||
} else if (diff < -180) {
|
} else if (diff < -180) {
|
||||||
to += 360;
|
normalizedTo += 360;
|
||||||
}
|
}
|
||||||
this.degreesSpring.springTo(to);
|
|
||||||
|
var reverseDiff = normalizedFrom - normalizedTo;
|
||||||
|
this.degreesSpring.resetTo(degrees + reverseDiff);
|
||||||
|
this.degreesSpring.springTo(degrees);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._setContentBounds(
|
this._setContentBounds(
|
||||||
|
@ -1075,7 +1075,7 @@
|
|||||||
|
|
||||||
viewport.setRotation(400);
|
viewport.setRotation(400);
|
||||||
assert.strictEqual(viewport.getRotation(true), 0, 'current rotation is not changed');
|
assert.strictEqual(viewport.getRotation(true), 0, 'current rotation is not changed');
|
||||||
assert.strictEqual(viewport.getRotation(false), 40, 'target rotation is set correctly');
|
assert.strictEqual(viewport.getRotation(false), 400, 'target rotation is set correctly');
|
||||||
|
|
||||||
viewport.setRotation(200, true);
|
viewport.setRotation(200, true);
|
||||||
assert.strictEqual(viewport.getRotation(true), 200, 'current rotation is set correctly');
|
assert.strictEqual(viewport.getRotation(true), 200, 'current rotation is set correctly');
|
||||||
|
Loading…
Reference in New Issue
Block a user