mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 03:13:41 +08:00
Merge branch 'master' of https://github.com/tole42/konva into tole42-master
This commit is contained in:
commit
a95eecbe4b
@ -520,18 +520,22 @@
|
||||
var newAlpha = Konva.Util._degToRad(newRotation);
|
||||
|
||||
var snaps = this.rotationSnaps();
|
||||
var offset = 0.1;
|
||||
var max = Math.PI * 2;
|
||||
var currentSnap = -1;
|
||||
for (var i = 0; i < snaps.length; i++) {
|
||||
var angle = Konva.getAngle(snaps[i]);
|
||||
|
||||
var dif =
|
||||
Math.abs(angle - Konva.Util._degToRad(newRotation)) % (Math.PI * 2);
|
||||
|
||||
if (dif < offset) {
|
||||
newRotation = Konva.Util._radToDeg(angle);
|
||||
newAlpha = Konva.Util._degToRad(newRotation);
|
||||
if (dif <= max) {
|
||||
max = dif;
|
||||
currentSnap = i;
|
||||
}
|
||||
}
|
||||
if (snaps.length > 0 && currentSnap >= 0) {
|
||||
angle = Konva.getAngle(snaps[currentSnap]);
|
||||
newRotation = Konva.Util._radToDeg(angle);
|
||||
newAlpha = Konva.Util._degToRad(newRotation);
|
||||
}
|
||||
|
||||
var dx = padding;
|
||||
var dy = padding;
|
||||
|
Loading…
Reference in New Issue
Block a user