mirror of
https://github.com/konvajs/konva.git
synced 2025-12-21 19:27:08 +08:00
rewrote cropping logic from last pull request, fixed serialization issue in unit test, added new unit tests, and added getX() and getY() methods
This commit is contained in:
26
src/Node.js
26
src/Node.js
@@ -158,6 +158,20 @@ Kinetic.Node.prototype = {
|
||||
this.attrs[key].y = val.y;
|
||||
}
|
||||
break;
|
||||
case 'crop':
|
||||
if(val.x !== undefined) {
|
||||
this.attrs[key].x = val.x;
|
||||
}
|
||||
if(val.y !== undefined) {
|
||||
this.attrs[key].y = val.y;
|
||||
}
|
||||
if(val.width !== undefined) {
|
||||
this.attrs[key].width = val.width;
|
||||
}
|
||||
if(val.height !== undefined) {
|
||||
this.attrs[key].height = val.height;
|
||||
}
|
||||
break;
|
||||
/*
|
||||
* config properties that we don't want in attrs
|
||||
*/
|
||||
@@ -289,6 +303,18 @@ Kinetic.Node.prototype = {
|
||||
setY: function(y) {
|
||||
this.attrs.y = y;
|
||||
},
|
||||
/**
|
||||
* get node x position
|
||||
*/
|
||||
getX: function() {
|
||||
return this.attrs.x;
|
||||
},
|
||||
/**
|
||||
* get node y position
|
||||
*/
|
||||
getY: function() {
|
||||
return this.attrs.y;
|
||||
},
|
||||
/**
|
||||
* set detection type
|
||||
* @param {String} type can be "path" or "pixel"
|
||||
|
||||
Reference in New Issue
Block a user