Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new events for transformations #4979

Merged
merged 16 commits into from
May 19, 2018
25 changes: 21 additions & 4 deletions src/canvas.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@
* @see {@link fabric.Canvas#initialize} for constructor definition
*
* @fires object:modified
* @fires object:rotated
* @fires object:scaled
* @fires object:moved
* @fires object:skewed
* @fires object:rotating
* @fires object:scaling
* @fires object:moving
* @fires object:skewing
* @fires object:selected this event is deprecated. use selection:created
*
* @fires before:transform
* @fires before:selection:cleared
* @fires selection:cleared
* @fires selection:updated
Expand All @@ -31,6 +37,9 @@
* @fires mouse:down
* @fires mouse:move
* @fires mouse:up
* @fires mouse:down:before
* @fires mouse:move:before
* @fires mouse:up:before
* @fires mouse:over
* @fires mouse:out
* @fires mouse:dblclick
Expand Down Expand Up @@ -695,6 +704,7 @@
};

this._resetCurrentTransform();
this._beforeTransform(e);
},

/**
Expand Down Expand Up @@ -1250,6 +1260,8 @@
* ignoreZoom true gives back coordinates after being processed
* by the viewportTransform ( sort of coordinates of what is displayed
* on the canvas where you are clicking.
* ignoreZoom true = HTMLElement coordinates relative to top,left
* ignoreZoom false, default = fabric space coordinates, the same used for shape position
* To interact with your shapes top and left you want to use ignoreZoom true
* most of the time, while ignoreZoom false will give you coordinates
* compatible with the object.oCoords system.
Expand All @@ -1258,11 +1270,17 @@
* @param {Boolean} ignoreZoom
* @return {Object} object with "x" and "y" number values
*/
getPointer: function (e, ignoreZoom, upperCanvasEl) {
if (!upperCanvasEl) {
upperCanvasEl = this.upperCanvasEl;
getPointer: function (e, ignoreZoom) {
// return cached values if we are in the event processing chain
if (this._absolutePointer && !ignoreZoom) {
return this._absolutePointer;
}
if (this._pointer && ignoreZoom) {
return this._pointer;
}

var pointer = getPointer(e),
upperCanvasEl = this.upperCanvasEl,
bounds = upperCanvasEl.getBoundingClientRect(),
boundsWidth = bounds.width || 0,
boundsHeight = bounds.height || 0,
Expand All @@ -1278,7 +1296,6 @@
}

this.calcOffset();

pointer.x = pointer.x - this._offset.left;
pointer.y = pointer.y - this._offset.top;
if (!ignoreZoom) {
Expand Down
Loading