mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-02 02:54:43 +00:00
- lockUniScaling now can't be overridden with shiftKey or uniScaleTransform property
- Pass event to object 'rotating' - some refactoring
This commit is contained in:
parent
2c662d32f4
commit
d03da23d0a
1 changed files with 31 additions and 50 deletions
|
|
@ -285,7 +285,7 @@
|
|||
var groupSelector = this._groupSelector;
|
||||
|
||||
// We initially clicked in an empty area, so we draw a box for multiple selection.
|
||||
if (groupSelector !== null) {
|
||||
if (groupSelector) {
|
||||
pointer = getPointer(e, this.upperCanvasEl);
|
||||
|
||||
groupSelector.left = pointer.x - this._offset.left - groupSelector.ex;
|
||||
|
|
@ -322,85 +322,66 @@
|
|||
pointer = getPointer(e, this.upperCanvasEl);
|
||||
|
||||
var x = pointer.x,
|
||||
y = pointer.y;
|
||||
y = pointer.y,
|
||||
reset = false,
|
||||
transform = this._currentTransform;
|
||||
|
||||
this._currentTransform.target.isMoving = true;
|
||||
target = transform.target;
|
||||
target.isMoving = true;
|
||||
|
||||
var t = this._currentTransform, reset = false;
|
||||
if (
|
||||
(t.action === 'scale' || t.action === 'scaleX' || t.action === 'scaleY')
|
||||
&&
|
||||
(
|
||||
// Switch from a normal resize to center-based
|
||||
(e.altKey && (t.originX !== 'center' || t.originY !== 'center'))
|
||||
||
|
||||
// Switch from center-based resize to normal one
|
||||
(!e.altKey && t.originX === 'center' && t.originY === 'center')
|
||||
)
|
||||
) {
|
||||
if ((transform.action === 'scale' || transform.action === 'scaleX' || transform.action === 'scaleY') &&
|
||||
// Switch from a normal resize to center-based
|
||||
((e.altKey && (transform.originX !== 'center' || transform.originY !== 'center')) ||
|
||||
// Switch from center-based resize to normal one
|
||||
(!e.altKey && transform.originX === 'center' && transform.originY === 'center'))
|
||||
) {
|
||||
this._resetCurrentTransform(e);
|
||||
reset = true;
|
||||
}
|
||||
|
||||
if (this._currentTransform.action === 'rotate') {
|
||||
if (transform.action === 'rotate') {
|
||||
this._rotateObject(x, y);
|
||||
|
||||
this.fire('object:rotating', {
|
||||
target: this._currentTransform.target,
|
||||
e: e
|
||||
});
|
||||
this._currentTransform.target.fire('rotating');
|
||||
this.fire('object:rotating', { target: target, e: e });
|
||||
target.fire('rotating', { e: e });
|
||||
}
|
||||
else if (this._currentTransform.action === 'scale') {
|
||||
else if (transform.action === 'scale') {
|
||||
// rotate object only if shift key is not pressed
|
||||
// and if it is not a group we are transforming
|
||||
|
||||
if (e.shiftKey || this.uniScaleTransform) {
|
||||
this._currentTransform.currentAction = 'scale';
|
||||
if ((e.shiftKey || this.uniScaleTransform) && !target.get('lockUniScaling')) {
|
||||
transform.currentAction = 'scale';
|
||||
this._scaleObject(x, y);
|
||||
}
|
||||
else {
|
||||
if (!reset && t.currentAction === 'scale') {
|
||||
// Switch from a normal resize to proportional
|
||||
// Switch from a normal resize to proportional
|
||||
if (!reset && transform.currentAction === 'scale') {
|
||||
this._resetCurrentTransform(e);
|
||||
}
|
||||
|
||||
this._currentTransform.currentAction = 'scaleEqually';
|
||||
transform.currentAction = 'scaleEqually';
|
||||
this._scaleObject(x, y, 'equally');
|
||||
}
|
||||
|
||||
this.fire('object:scaling', {
|
||||
target: this._currentTransform.target,
|
||||
e: e
|
||||
});
|
||||
this._currentTransform.target.fire('scaling', { e: e });
|
||||
this.fire('object:scaling', { target: target, e: e });
|
||||
target.fire('scaling', { e: e });
|
||||
}
|
||||
else if (this._currentTransform.action === 'scaleX') {
|
||||
else if (transform.action === 'scaleX') {
|
||||
this._scaleObject(x, y, 'x');
|
||||
|
||||
this.fire('object:scaling', {
|
||||
target: this._currentTransform.target,
|
||||
e: e
|
||||
});
|
||||
this._currentTransform.target.fire('scaling', { e: e });
|
||||
this.fire('object:scaling', { target: target, e: e});
|
||||
target.fire('scaling', { e: e });
|
||||
}
|
||||
else if (this._currentTransform.action === 'scaleY') {
|
||||
else if (transform.action === 'scaleY') {
|
||||
this._scaleObject(x, y, 'y');
|
||||
|
||||
this.fire('object:scaling', {
|
||||
target: this._currentTransform.target,
|
||||
e: e
|
||||
});
|
||||
this._currentTransform.target.fire('scaling', { e: e });
|
||||
this.fire('object:scaling', { target: target, e: e});
|
||||
target.fire('scaling', { e: e });
|
||||
}
|
||||
else {
|
||||
this._translateObject(x, y);
|
||||
|
||||
this.fire('object:moving', {
|
||||
target: this._currentTransform.target,
|
||||
e: e
|
||||
});
|
||||
this._currentTransform.target.fire('moving', { e: e });
|
||||
this.fire('object:moving', { target: target, e: e});
|
||||
target.fire('moving', { e: e });
|
||||
this._setCursor(this.moveCursor);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue