mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-07 07:51:00 +00:00
Added: 'object:removed' event
Inlined removeFromArray call (because it didn't return whether indexOf returned -1 or not so I couldn't know if 'object:removed' had to be fired or not
This commit is contained in:
parent
bf61e2a2b0
commit
fd4a9733d4
1 changed files with 11 additions and 3 deletions
|
|
@ -959,14 +959,22 @@
|
|||
* @return {Object} removed object
|
||||
*/
|
||||
remove: function (object) {
|
||||
removeFromArray(this._objects, object);
|
||||
// removing active object should fire "selection:cleared" events
|
||||
if (this.getActiveObject() === object) {
|
||||
|
||||
// removing active object should fire "selection:cleared" events
|
||||
this.fire('before:selection:cleared', { target: object });
|
||||
this.discardActiveObject();
|
||||
this.fire('selection:cleared');
|
||||
}
|
||||
|
||||
var objects = this._objects;
|
||||
var index = objects.indexOf(object);
|
||||
|
||||
// removing any object should fire "objct:removed" events
|
||||
if (index !== -1) {
|
||||
objects.splice(index,1);
|
||||
this.fire('object:removed', { target: object });
|
||||
}
|
||||
|
||||
this.renderAll();
|
||||
return object;
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue