diff --git a/demos/events/index.html b/demos/events/index.html index 719205ab..ec715351 100644 --- a/demos/events/index.html +++ b/demos/events/index.html @@ -57,16 +57,12 @@ } observe('object:modified'); - observe('object:moved'); - observe('object:scaled'); + observe('object:moving'); observe('object:selected'); + observe('before:selection:cleared'); observe('selection:cleared'); - - observe('group:modified'); - observe('group:selected'); - observe('before:group:destroyed'); - observe('after:group:destroyed'); + observe('selection:created'); // observe('after:render'); observe('mouse:up'); diff --git a/dist/all.js b/dist/all.js index 05561a57..fd386c65 100644 --- a/dist/all.js +++ b/dist/all.js @@ -4385,7 +4385,6 @@ fabric.util.getElementOffset = getElementOffset; target = transform.target; if (target._scaling) { - this.fire('object:scaled', { target: target }); target._scaling = false; } @@ -4407,10 +4406,6 @@ fabric.util.getElementOffset = getElementOffset; } var activeGroup = this.getActiveGroup(); if (activeGroup) { - if (this.stateful && activeGroup.hasStateChanged() && - activeGroup.containsPoint(this.getPointer(e))) { - this.fire('group:modified', { target: activeGroup }); - } activeGroup.setObjectsCoords(); activeGroup.set('isMoving', false); this._setCursor('default'); @@ -4524,17 +4519,14 @@ fabric.util.getElementOffset = getElementOffset; * @return {fabric.Canvas} thisArg */ deactivateAllWithDispatch: function () { - var activeGroup = this.getActiveGroup(); - if (activeGroup) { - this.fire('before:group:destroyed', { - target: activeGroup - }); + var activeObject = this.getActiveGroup() || this.getActiveObject(); + if (activeObject) { + this.fire('before:selection:cleared', { target: activeObject }); } this.deactivateAll(); - if (activeGroup) { - this.fire('after:group:destroyed'); + if (activeObject) { + this.fire('selection:cleared'); } - this.fire('selection:cleared'); return this; }, @@ -4595,7 +4587,7 @@ fabric.util.getElementOffset = getElementOffset; else { activeGroup.add(target); } - this.fire('group:selected', { target: activeGroup }); + this.fire('selection:created', { target: activeGroup }); activeGroup.setActive(true); } else { @@ -4768,7 +4760,7 @@ fabric.util.getElementOffset = getElementOffset; else { this._translateObject(x, y); - this.fire('object:moved', { + this.fire('object:moving', { target: this._currentTransform.target }); } @@ -4957,7 +4949,7 @@ fabric.util.getElementOffset = getElementOffset; var group = new fabric.Group(group); this.setActiveGroup(group); group.saveCoords(); - this.fire('group:selected', { target: group }); + this.fire('selection:created', { target: group }); } this.renderAll(); diff --git a/lib/aligning_guidelines.js b/lib/aligning_guidelines.js index 05e56d19..05a3a0fa 100644 --- a/lib/aligning_guidelines.js +++ b/lib/aligning_guidelines.js @@ -53,7 +53,7 @@ function initAligningGuidelines(canvas) { var verticalLines = [ ], horizontalLines = [ ]; - canvas.observe('object:moved', function(e) { + canvas.observe('object:moving', function(e) { var activeObject = e.memo.target, canvasObjects = canvas.getObjects(), diff --git a/lib/centering_guidelines.js b/lib/centering_guidelines.js index 8963bec3..13a26565 100644 --- a/lib/centering_guidelines.js +++ b/lib/centering_guidelines.js @@ -47,7 +47,7 @@ function initCenteringGuidelines(canvas) { isInVerticalCenter, isInHorizontalCenter; - canvas.observe('object:moved', function(e) { + canvas.observe('object:moving', function(e) { object = e.memo.target; isInVerticalCenter = object.get('left') in canvasWidthCenterMap, diff --git a/src/canvas.class.js b/src/canvas.class.js index c9173cf0..6ca7a174 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -511,7 +511,6 @@ target = transform.target; if (target._scaling) { - this.fire('object:scaled', { target: target }); target._scaling = false; } @@ -536,10 +535,6 @@ } var activeGroup = this.getActiveGroup(); if (activeGroup) { - if (this.stateful && activeGroup.hasStateChanged() && - activeGroup.containsPoint(this.getPointer(e))) { - this.fire('group:modified', { target: activeGroup }); - } activeGroup.setObjectsCoords(); activeGroup.set('isMoving', false); this._setCursor('default'); @@ -661,17 +656,14 @@ * @return {fabric.Canvas} thisArg */ deactivateAllWithDispatch: function () { - var activeGroup = this.getActiveGroup(); - if (activeGroup) { - this.fire('before:group:destroyed', { - target: activeGroup - }); + var activeObject = this.getActiveGroup() || this.getActiveObject(); + if (activeObject) { + this.fire('before:selection:cleared', { target: activeObject }); } this.deactivateAll(); - if (activeGroup) { - this.fire('after:group:destroyed'); + if (activeObject) { + this.fire('selection:cleared'); } - this.fire('selection:cleared'); return this; }, @@ -735,7 +727,7 @@ else { activeGroup.add(target); } - this.fire('group:selected', { target: activeGroup }); + this.fire('selection:created', { target: activeGroup }); activeGroup.setActive(true); } else { @@ -928,7 +920,7 @@ else { this._translateObject(x, y); - this.fire('object:moved', { + this.fire('object:moving', { target: this._currentTransform.target }); } @@ -1120,7 +1112,7 @@ var group = new fabric.Group(group); this.setActiveGroup(group); group.saveCoords(); - this.fire('group:selected', { target: group }); + this.fire('selection:created', { target: group }); } this.renderAll();