added scale save and restore logic to drag and drop operation

This commit is contained in:
Eric Rowell 2012-03-25 23:56:38 -07:00
parent eaab71e242
commit d8c5ca24af
3 changed files with 35 additions and 5 deletions

19
dist/kinetic-core.js vendored
View File

@ -1604,9 +1604,20 @@ Kinetic.Stage.prototype = {
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 scale = {
x: node.scale.x,
y: node.scale.y
};
node.rotation = 0;
node.scale = {
x: 1,
y: 1
};
// unravel transform
var it = node.getAbsoluteTransform();
@ -1616,8 +1627,12 @@ Kinetic.Stage.prototype = {
node.x += it.getTranslation().x;
node.y += it.getTranslation().y;
// restore rotation
// restore rotation and scale
node.rotate(rot);
node.scale = {
x: scale.x,
y: scale.y
};
go.drag.node.getLayer().draw();

File diff suppressed because one or more lines are too long

View File

@ -624,9 +624,20 @@ Kinetic.Stage.prototype = {
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 scale = {
x: node.scale.x,
y: node.scale.y
};
node.rotation = 0;
node.scale = {
x: 1,
y: 1
};
// unravel transform
var it = node.getAbsoluteTransform();
@ -636,8 +647,12 @@ Kinetic.Stage.prototype = {
node.x += it.getTranslation().x;
node.y += it.getTranslation().y;
// restore rotation
// restore rotation and scale
node.rotate(rot);
node.scale = {
x: scale.x,
y: scale.y
};
go.drag.node.getLayer().draw();