mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-03 03:24:42 +00:00
Move getLocalPointer to fabric.Object
This commit is contained in:
parent
31338df54d
commit
5fdc1dc2d1
2 changed files with 15 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue