mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
added scale save and restore logic to drag and drop operation
This commit is contained in:
parent
eaab71e242
commit
d8c5ca24af
19
dist/kinetic-core.js
vendored
19
dist/kinetic-core.js
vendored
@ -1604,9 +1604,20 @@ Kinetic.Stage.prototype = {
|
|||||||
newNodePos.x = node.x;
|
newNodePos.x = node.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// save rotation and remove it from transform
|
/*
|
||||||
|
* save rotation and scale and then
|
||||||
|
* remove them from the transform
|
||||||
|
*/
|
||||||
var rot = node.rotation;
|
var rot = node.rotation;
|
||||||
|
var scale = {
|
||||||
|
x: node.scale.x,
|
||||||
|
y: node.scale.y
|
||||||
|
};
|
||||||
node.rotation = 0;
|
node.rotation = 0;
|
||||||
|
node.scale = {
|
||||||
|
x: 1,
|
||||||
|
y: 1
|
||||||
|
};
|
||||||
|
|
||||||
// unravel transform
|
// unravel transform
|
||||||
var it = node.getAbsoluteTransform();
|
var it = node.getAbsoluteTransform();
|
||||||
@ -1616,8 +1627,12 @@ Kinetic.Stage.prototype = {
|
|||||||
node.x += it.getTranslation().x;
|
node.x += it.getTranslation().x;
|
||||||
node.y += it.getTranslation().y;
|
node.y += it.getTranslation().y;
|
||||||
|
|
||||||
// restore rotation
|
// restore rotation and scale
|
||||||
node.rotate(rot);
|
node.rotate(rot);
|
||||||
|
node.scale = {
|
||||||
|
x: scale.x,
|
||||||
|
y: scale.y
|
||||||
|
};
|
||||||
|
|
||||||
go.drag.node.getLayer().draw();
|
go.drag.node.getLayer().draw();
|
||||||
|
|
||||||
|
2
dist/kinetic-core.min.js
vendored
2
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
19
src/Stage.js
19
src/Stage.js
@ -624,9 +624,20 @@ Kinetic.Stage.prototype = {
|
|||||||
newNodePos.x = node.x;
|
newNodePos.x = node.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// save rotation and remove it from transform
|
/*
|
||||||
|
* save rotation and scale and then
|
||||||
|
* remove them from the transform
|
||||||
|
*/
|
||||||
var rot = node.rotation;
|
var rot = node.rotation;
|
||||||
|
var scale = {
|
||||||
|
x: node.scale.x,
|
||||||
|
y: node.scale.y
|
||||||
|
};
|
||||||
node.rotation = 0;
|
node.rotation = 0;
|
||||||
|
node.scale = {
|
||||||
|
x: 1,
|
||||||
|
y: 1
|
||||||
|
};
|
||||||
|
|
||||||
// unravel transform
|
// unravel transform
|
||||||
var it = node.getAbsoluteTransform();
|
var it = node.getAbsoluteTransform();
|
||||||
@ -636,8 +647,12 @@ Kinetic.Stage.prototype = {
|
|||||||
node.x += it.getTranslation().x;
|
node.x += it.getTranslation().x;
|
||||||
node.y += it.getTranslation().y;
|
node.y += it.getTranslation().y;
|
||||||
|
|
||||||
// restore rotation
|
// restore rotation and scale
|
||||||
node.rotate(rot);
|
node.rotate(rot);
|
||||||
|
node.scale = {
|
||||||
|
x: scale.x,
|
||||||
|
y: scale.y
|
||||||
|
};
|
||||||
|
|
||||||
go.drag.node.getLayer().draw();
|
go.drag.node.getLayer().draw();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user