Move getLocalPointer to fabric.Object

This commit is contained in:
kangax 2013-11-11 18:34:46 +01:00
parent 31338df54d
commit 5fdc1dc2d1
2 changed files with 15 additions and 13 deletions

View file

@ -891,19 +891,6 @@
this.setSelectionEnd(newSelectionEnd);
},
/**
* Returns coordinates of a pointer relative to an object
* @return {Object} Coordinates of a pointer (x, y)
*/
getLocalPointer: function(e) {
var pointer = this.canvas.getPointer(e);
var objectLeftTop = this.translateToOriginPoint(this.getCenterPoint(), 'left', 'top');
return {
x: pointer.x - objectLeftTop.x,
y: pointer.y - objectLeftTop.y
};
},
/**
* Changes cursor location in a text depending on passed pointer (x/y) object
* @param {Object} pointer Pointer object with x and y numeric properties

View file

@ -1499,6 +1499,21 @@
this.canvas.moveTo(this, index);
}
return this;
},
/**
* Returns coordinates of a pointer relative to an object
* @param {Event} e Event to operate upon
* @param {Object} [pointer] Pointer to operate upon (instead of event)
* @return {Object} Coordinates of a pointer (x, y)
*/
getLocalPointer: function(e, pointer) {
pointer = pointer || this.canvas.getPointer(e);
var objectLeftTop = this.translateToOriginPoint(this.getCenterPoint(), 'left', 'top');
return {
x: pointer.x - objectLeftTop.x,
y: pointer.y - objectLeftTop.y
};
}
});