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:
FremyCompany 2013-01-18 16:16:40 +01:00
parent bf61e2a2b0
commit fd4a9733d4

View file

@ -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;
},