diff --git a/CHANGELOG.md b/CHANGELOG.md
index 40455b66ed1..8fd8cc27808 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,12 +2,13 @@
## [4.0.0-beta.8]
-- fix(svg_parsers): Add support for empty tags [#6169](https://github.com/fabricjs/fabric.js/pull/)
-- fix(SVG_export, text): Check font faces markup for objects within groups [#6195](https://github.com/fabricjs/fabric.js/pull/)
-- feat(animation): Extend fabric.util.animate animating colors and other properties[#6191](https://github.com/fabricjs/fabric.js/pull/)
-- fix(svg_export): remove extra space from svg export [#6209](https://github.com/fabricjs/fabric.js/pull/)
-- fix(svg_import): ISSUE-6170 do not try to create missing clippath [#6210](https://github.com/fabricjs/fabric.js/pull/)
-- fix(fabric.Object) Adding existence check for this.canvas on object stacking mixins [#6207](https://github.com/fabricjs/fabric.js/pull/)
+- fix(fabric.Object): fix activeSelection toDataURL canvas restore [#6216](https://github.com/fabricjs/fabric.js/pull/6216)
+- fix(svg_parsers): Add support for empty tags [#6169](https://github.com/fabricjs/fabric.js/pull/6169)
+- fix(SVG_export, text): Check font faces markup for objects within groups [#6195](https://github.com/fabricjs/fabric.js/pull/6195)
+- feat(animation): Extend fabric.util.animate animating colors and other properties[#6191](https://github.com/fabricjs/fabric.js/pull/6191)
+- fix(svg_export): remove extra space from svg export [#6209](https://github.com/fabricjs/fabric.js/pull/6209)
+- fix(svg_import): ISSUE-6170 do not try to create missing clippath [#6210](https://github.com/fabricjs/fabric.js/pull/6210)
+- fix(fabric.Object) Adding existence check for this.canvas on object stacking mixins [#6207](https://github.com/fabricjs/fabric.js/pull/6207)
## [4.0.0-beta.7]
diff --git a/src/controls.actions.js b/src/controls.actions.js
index 4b12c9dd12b..4e9ad1d44f3 100644
--- a/src/controls.actions.js
+++ b/src/controls.actions.js
@@ -21,19 +21,41 @@
target.fire(eventName, options);
}
- function scaleCursorStyleHandler(eventData, corner, fabricObject) {
- var canvas = fabricObject.canvas, uniScaleKey = canvas.uniScaleKey, notAllowed = 'not-allowed',
- uniformIsToggled = eventData[uniScaleKey],
- scaleIsProportional = (canvas.uniformScaling && !uniformIsToggled) ||
- (!canvas.uniformScaling && uniformIsToggled);
+ function scaleIsProportional(eventData, fabricObject) {
+ var canvas = fabricObject.canvas, uniScaleKey = canvas.uniScaleKey,
+ uniformIsToggled = eventData[uniScaleKey];
+ return (canvas.uniformScaling && !uniformIsToggled) ||
+ (!canvas.uniformScaling && uniformIsToggled);
+ }
- if (fabricObject.lockScalingX && fabricObject.lockScalingY) {
- return notAllowed;
+ function scalingIsForbidden(fabricObject, by, scaleProportionally) {
+ var lockX = fabricObject.lockScalingX, lockY = fabricObject.lockScalingY;
+ if (lockX && lockY) {
+ return true;
}
- if (corner.x !== 0 && fabricObject.lockScalingX && scaleIsProportional) {
- return notAllowed;
+ if (!by && (lockX || lockY) && scaleProportionally) {
+ return true;
+ }
+ if (lockX && by === 'x') {
+ return true;
+ }
+ if (lockY && by === 'y') {
+ return true;
+ }
+ return false;
+ }
+
+ function scaleCursorStyleHandler(eventData, corner, fabricObject) {
+ var notAllowed = 'not-allowed',
+ scaleProportionally = scaleIsProportional(eventData, fabricObject),
+ by = '';
+ if (corner.x !== 0 && corner.y === 0) {
+ by = 'x';
+ }
+ else if (corner.x === 0 && corner.y !== 0) {
+ by = 'y';
}
- if (corner.y !== 0 && fabricObject.lockScalingY && scaleIsProportional) {
+ if (scalingIsForbidden(fabricObject, by, scaleProportionally)) {
return notAllowed;
}
var n = findCornerQuadrant(fabricObject, corner);
@@ -341,15 +363,12 @@
function scaleObject(eventData, transform, x, y, options) {
options = options || {};
var target = transform.target,
- uniScaleKey = target.canvas.uniScaleKey, isUniScalePressed = eventData[uniScaleKey],
lockScalingX = target.lockScalingX, lockScalingY = target.lockScalingY,
- by = options.by, newPoint, scaleX, scaleY, dim;
-
- if (!isUniScalePressed && (lockScalingX || lockScalingY)) {
- return false;
- }
+ by = options.by, newPoint, scaleX, scaleY, dim,
+ scaleProportionally = scaleIsProportional(eventData, target),
+ forbidScaling = scalingIsForbidden(target, by, scaleProportionally);
- if (isUniScalePressed && lockScalingX && lockScalingY) {
+ if (forbidScaling) {
return false;
}
@@ -357,7 +376,7 @@
newPoint = getLocalPoint(target, transform.originX, transform.originY, x, y);
// missing detection of flip and logic to switch the origin
- if (!isUniScalePressed && !by) {
+ if (scaleProportionally && !by) {
// uniform scaling
var distance = Math.abs(newPoint.x) + Math.abs(newPoint.y),
original = transform.original,
@@ -379,10 +398,11 @@
// minScale is taken are in the setter.
var oldScaleX = target.scaleX, oldScaleY = target.scaleY;
if (!by) {
- target.set('scaleX', scaleX);
- target.set('scaleY', scaleY);
+ !lockScalingX && target.set('scaleX', scaleX);
+ !lockScalingY && target.set('scaleY', scaleY);
}
else {
+ // forbidden cases already handled on top here.
by === 'x' && target.set('scaleX', scaleX);
by === 'y' && target.set('scaleY', scaleY);
}