mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-10 14:54:42 +00:00
Refactor _handleGroupLogic
This commit is contained in:
parent
4bc80ab816
commit
c0c222f672
1 changed files with 24 additions and 20 deletions
|
|
@ -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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue