mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-16 22:10:32 +00:00
Merge pull request #2269 from asturur/fix-rotated-poi
Fix rotated pointer
This commit is contained in:
commit
0d83da0e29
2 changed files with 9 additions and 21 deletions
|
|
@ -156,30 +156,13 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Event} e Event object
|
||||
* @return {Object} Coordinates of a pointer (x, y)
|
||||
*/
|
||||
_getLocalRotatedPointer: function(e) {
|
||||
var pointer = this.canvas.getPointer(e),
|
||||
|
||||
pClicked = new fabric.Point(pointer.x, pointer.y),
|
||||
pLeftTop = new fabric.Point(this.left, this.top),
|
||||
|
||||
rotated = fabric.util.rotatePoint(
|
||||
pClicked, pLeftTop, fabric.util.degreesToRadians(-this.angle));
|
||||
|
||||
return this.getLocalPointer(e, rotated);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns index of a character corresponding to where an object was clicked
|
||||
* @param {Event} e Event object
|
||||
* @return {Number} Index of a character
|
||||
*/
|
||||
getSelectionStartFromPointer: function(e) {
|
||||
var mouseOffset = this._getLocalRotatedPointer(e),
|
||||
var mouseOffset = this._getLocalPointer(e),
|
||||
prevWidth = 0,
|
||||
width = 0,
|
||||
height = 0,
|
||||
|
|
|
|||
|
|
@ -1464,10 +1464,15 @@
|
|||
*/
|
||||
getLocalPointer: function(e, pointer) {
|
||||
pointer = pointer || this.canvas.getPointer(e);
|
||||
var objectLeftTop = this.translateToOriginPoint(this.getCenterPoint(), 'left', 'top');
|
||||
var pClicked = new fabric.Point(pointer.x, pointer.y),
|
||||
objectLeftTop = this._getLeftTopCoords();
|
||||
if (this.angle) {
|
||||
pClicked = fabric.util.rotatePoint(
|
||||
pClicked, objectLeftTop, fabric.util.degreesToRadians(-this.angle));
|
||||
}
|
||||
return {
|
||||
x: pointer.x - objectLeftTop.x,
|
||||
y: pointer.y - objectLeftTop.y
|
||||
x: pClicked.x - objectLeftTop.x,
|
||||
y: pClicked.y - objectLeftTop.y
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue