Refactor _handleGroupLogic

This commit is contained in:
kangax 2013-10-25 10:38:32 +02:00
parent 4bc80ab816
commit c0c222f672

View file

@ -504,29 +504,33 @@
activeGroup.set('active', true);
}
else {
// group does not exist
if (this._activeObject) {
// only if there's an active object
if (target !== this._activeObject) {
// and that object is not the actual target
var objects = this.getObjects();
var isActiveLower = objects.indexOf(this._activeObject) < objects.indexOf(target);
var group = new fabric.Group(
isActiveLower ? [ target, this._activeObject ] : [ this._activeObject, target ]);
this._createActiveGroup(target, e);
}
this.setActiveGroup(group);
this._activeObject = null;
activeGroup = this.getActiveGroup();
this.fire('selection:created', { target: activeGroup, e: e });
}
if (this._activeGroup) {
this._activeGroup.saveCoords();
}
},
_createActiveGroup: function(target, e) {
// group does not exist
if (this._activeObject) {
// only if there's an active object
if (target !== this._activeObject) {
// and that object is not the actual target
var objects = this.getObjects();
var isActiveLower = objects.indexOf(this._activeObject) < objects.indexOf(target);
var group = new fabric.Group(
isActiveLower ? [ target, this._activeObject ] : [ this._activeObject, target ]);
this.setActiveGroup(group);
this._activeObject = null;
var activeGroup = this.getActiveGroup();
this.fire('selection:created', { target: activeGroup, e: e });
}
// activate target object in any case
target.set('active', true);
}
if (activeGroup) {
activeGroup.saveCoords();
}
// activate target object in any case
target.set('active', true);
},
/**