mirror of
https://github.com/konvajs/konva.git
synced 2025-12-21 19:27:08 +08:00
refactored setAbsolutePosition() method and Shape _draw method
This commit is contained in:
23
src/Node.js
23
src/Node.js
@@ -306,17 +306,24 @@ Kinetic.Node.prototype = {
|
||||
},
|
||||
/**
|
||||
* set absolute position relative to stage
|
||||
* @param {Object} pos object containing an x and
|
||||
* y property
|
||||
*/
|
||||
setAbsolutePosition: function(pos, override) {
|
||||
setAbsolutePosition: function(pos) {
|
||||
/*
|
||||
* save rotation and scale and then
|
||||
* remove them from the transform
|
||||
* save rotation and scale and
|
||||
* then remove them from the transform
|
||||
*/
|
||||
var rot = this.attrs.rotation;
|
||||
var scale = {
|
||||
x: this.attrs.scale.x,
|
||||
y: this.attrs.scale.y
|
||||
};
|
||||
var centerOffset = {
|
||||
x: this.attrs.centerOffset.x,
|
||||
y: this.attrs.centerOffset.y
|
||||
};
|
||||
|
||||
this.attrs.rotation = 0;
|
||||
this.attrs.scale = {
|
||||
x: 1,
|
||||
@@ -332,16 +339,6 @@ Kinetic.Node.prototype = {
|
||||
y: this.attrs.y + it.getTranslation().y
|
||||
};
|
||||
|
||||
// handle override
|
||||
if(override !== undefined) {
|
||||
if(override.x !== undefined) {
|
||||
pos.x = override.x;
|
||||
}
|
||||
if(override.y !== undefined) {
|
||||
pos.y = override.y;
|
||||
}
|
||||
}
|
||||
|
||||
this.setPosition(pos.x, pos.y);
|
||||
|
||||
// restore rotation and scale
|
||||
|
||||
Reference in New Issue
Block a user