Skip to content

Commit

Permalink
Version 3.6.3 (#6214)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Mar 15, 2020
1 parent ea06560 commit c80c3e7
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 114 deletions.
36 changes: 9 additions & 27 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,15 @@

## [3.6.3]

backport: fix(fabric.Group): will draw shadow will call parent method. [#6116](https://github.com/fabricjs/fabric.js/pull/6116)
backport: fix(fabric.Object): getObjectScaling takes in account rotation of objects inside groups. [#6118](https://github.com/fabricjs/fabric.js/pull/6118)
backport: fix(fabric.Object): getObjectScaling takes in account rotation of objects inside groups. [#6118](https://github.com/fabricjs/fabric.js/pull/6118)

## [4.0.0-beta.5]

fix(fabric.Object): getObjectScaling takes in account rotation of objects inside groups. [#6118](https://github.com/fabricjs/fabric.js/pull/6118)

## [4.0.0-beta.4]

fix(fabric.Group): will draw shadow will call parent method. [#6116](https://github.com/fabricjs/fabric.js/pull/6116)

## [4.0.0-beta.3]

fix(controls): control offset rendering code had extras `beginPath` that would clear all but not the last of them [#6114](https://github.com/fabricjs/fabric.js/pull/6114)

## [4.0.0-beta.2]

fix(controls): Control.getVisibility will always receive the fabric.Object argument.

## [4.0.0-beta.1]

breaking: All your old control code override will not work
breaking: `uniScaleTransform` has been renamed in `uniformScaling`, meaning changed and the default value swapped. The behaviour is unchanged, but now the description and the name match.
breaking: LockScalingFlip with the scaling flip behaviour are missing now, maybe reimplemented later.
breaking: Object.lockUniScaling is removed. Alternatives to get the same identical functionality with less code are being evaluated.
breaking: Canvas.onBeforeScaleRotate is removed, developers need to migrate to the event `before:transform
- fix(Object): ISSUE 6196 use set('canvas') to restore canvas #6216
- fix(fabric.IText): exitEditing won't error on missing hiddenTextarea. #6138
- fix(fabric.Object): getObjectScaling takes in account rotation of objects inside groups. #6118
- fix(fabric.Group): will draw shadow will call parent method. #6116
- fix(svg_parsers): Add support for empty <style/> tags (#6169)
- fix(SVG_export, text): Check font faces markup for objects within groups (#6195)
- fix(svg_export): remove extra space from svg export (#6209)
- fix(svg_import): ISSUE-6170 do not try to create missing clippath (#6210)
- fix(fabric.Object) Adding existence check for this.canvas on object stacking mixins (#6207)

## [3.6.2]
- fix fabric.Object.toDataURL blurriness on images with odd pixel number [#6131](https://github.com/fabricjs/fabric.js/pull/6131)
Expand Down
115 changes: 78 additions & 37 deletions dist/fabric.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* build: `node build.js modules=ALL exclude=gestures,accessors requirejs minifier=uglifyjs` */
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */

var fabric = fabric || { version: '3.6.2' };
var fabric = fabric || { version: '3.6.3' };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}
Expand Down Expand Up @@ -1575,10 +1575,36 @@ fabric.CommonMethods = {
return Math.max(min, Math.min(value, max));
},

/**
* Finds the scale for the object source to fit inside the object destination,
* keeping aspect ratio intact.
* respect the total allowed area for the cache.
* @memberOf fabric.util
* @param {Object | fabric.Object} source
* @param {Number} source.height natural unscaled height of the object
* @param {Number} source.width natural unscaled width of the object
* @param {Object | fabric.Object} destination
* @param {Number} destination.height natural unscaled height of the object
* @param {Number} destination.width natural unscaled width of the object
* @return {Number} scale factor to apply to source to fit into destination
*/
findScaleToFit: function(source, destination) {
return Math.min(destination.width / source.width, destination.height / source.height);
},

/**
* Finds the scale for the object source to cover entirely the object destination,
* keeping aspect ratio intact.
* respect the total allowed area for the cache.
* @memberOf fabric.util
* @param {Object | fabric.Object} source
* @param {Number} source.height natural unscaled height of the object
* @param {Number} source.width natural unscaled width of the object
* @param {Object | fabric.Object} destination
* @param {Number} destination.height natural unscaled height of the object
* @param {Number} destination.width natural unscaled width of the object
* @return {Number} scale factor to apply to source to cover destination
*/
findScaleToCover: function(source, destination) {
return Math.max(destination.width / source.width, destination.height / source.height);
},
Expand Down Expand Up @@ -4281,8 +4307,8 @@ fabric.warn = console.warn;

// very crude parsing of style contents
for (i = 0, len = styles.length; i < len; i++) {
// IE9 doesn't support textContent, but provides text instead.
var styleContents = styles[i].textContent || styles[i].text;
// <style/> could produce `undefined`, covering this case with ''
var styleContents = styles[i].textContent || '';

// remove comments
styleContents = styleContents.replace(/\/\*[\s\S]*?\*\//g, '');
Expand Down Expand Up @@ -4530,6 +4556,10 @@ fabric.ElementsParser = function(elements, callback, options, reviver, parsingOp
clipPath.setPositionByOrigin({ x: options.translateX, y: options.translateY }, 'center', 'center');
obj.clipPath = clipPath;
}
else {
// if clip-path does not resolve to any element, delete the property.
delete obj.clipPath;
}
};

proto.checkIfDone = function() {
Expand Down Expand Up @@ -8046,7 +8076,14 @@ fabric.ElementsParser = function(elements, callback, options, reviver, parsingOp
createSVGFontFacesMarkup: function() {
var markup = '', fontList = { }, obj, fontFamily,
style, row, rowIndex, _char, charIndex, i, len,
fontPaths = fabric.fontPaths, objects = this._objects;
fontPaths = fabric.fontPaths, objects = [];

this._objects.forEach(function add(object) {
objects.push(object);
if (object._objects) {
object._objects.forEach(add);
}
});

for (i = 0, len = objects.length; i < len; i++) {
obj = objects[i];
Expand Down Expand Up @@ -13125,6 +13162,9 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati

/**
* Scale factor of object's controlling borders
* bigger number will make a thicker border
* border is 1, so this is basically a border tickness
* since there is no way to change the border itself.
* @type Number
* @default
*/
Expand Down Expand Up @@ -13629,6 +13669,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
strokeLineCap: this.strokeLineCap,
strokeDashOffset: this.strokeDashOffset,
strokeLineJoin: this.strokeLineJoin,
// TODO: add this before release
// strokeUniform: this.strokeUniform,
strokeMiterLimit: toFixed(this.strokeMiterLimit, NUM_FRACTION_DIGITS),
scaleX: toFixed(this.scaleX, NUM_FRACTION_DIGITS),
scaleY: toFixed(this.scaleY, NUM_FRACTION_DIGITS),
Expand Down Expand Up @@ -13711,13 +13753,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
* @return {Object} object with scaleX and scaleY properties
*/
getObjectScaling: function() {
var scaleX = this.scaleX, scaleY = this.scaleY;
if (this.group) {
var scaling = this.group.getObjectScaling();
scaleX *= scaling.scaleX;
scaleY *= scaling.scaleY;
}
return { scaleX: scaleX, scaleY: scaleY };
var options = fabric.util.qrDecompose(this.calcTransformMatrix());
return { scaleX: Math.abs(options.scaleX), scaleY: Math.abs(options.scaleY) };
},

/**
Expand Down Expand Up @@ -14304,7 +14341,11 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
}

ctx.save();
if (this.strokeUniform) {
if (this.strokeUniform && this.group) {
var scaling = this.getObjectScaling();
ctx.scale(1 / scaling.scaleX, 1 / scaling.scaleY);
}
else if (this.strokeUniform) {
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
}
this._setLineDash(ctx, this.strokeDashArray, this._renderDashedStroke);
Expand Down Expand Up @@ -14466,7 +14507,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
* @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4
* @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4
* @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2
* @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format
* @return {HTMLCanvasElement} Returns DOM element <canvas> with the fabric.Object
*/
toCanvasElement: function(options) {
options || (options = { });
Expand Down Expand Up @@ -14522,7 +14563,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
canvas.add(this);
var canvasEl = canvas.toCanvasElement(multiplier || 1, options);
this.shadow = originalShadow;
this.canvas = originalCanvas;
this.set('canvas', originalCanvas);
if (originalGroup) {
this.group = originalGroup;
}
Expand Down Expand Up @@ -15813,7 +15854,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
if (this.group) {
fabric.StaticCanvas.prototype.sendToBack.call(this.group, this);
}
else {
else if (this.canvas) {
this.canvas.sendToBack(this);
}
return this;
Expand All @@ -15828,7 +15869,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
if (this.group) {
fabric.StaticCanvas.prototype.bringToFront.call(this.group, this);
}
else {
else if (this.canvas) {
this.canvas.bringToFront(this);
}
return this;
Expand All @@ -15844,7 +15885,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
if (this.group) {
fabric.StaticCanvas.prototype.sendBackwards.call(this.group, this, intersecting);
}
else {
else if (this.canvas) {
this.canvas.sendBackwards(this, intersecting);
}
return this;
Expand All @@ -15860,7 +15901,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
if (this.group) {
fabric.StaticCanvas.prototype.bringForward.call(this.group, this, intersecting);
}
else {
else if (this.canvas) {
this.canvas.bringForward(this, intersecting);
}
return this;
Expand All @@ -15876,7 +15917,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
if (this.group && this.group.type !== 'activeSelection') {
fabric.StaticCanvas.prototype.moveTo.call(this.group, this, index);
}
else {
else if (this.canvas) {
this.canvas.moveTo(this, index);
}
return this;
Expand Down Expand Up @@ -15988,11 +16029,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
* @return {String}
*/
getSvgTextDecoration: function(style) {
if ('overline' in style || 'underline' in style || 'linethrough' in style) {
return (style.overline ? 'overline ' : '') +
(style.underline ? 'underline ' : '') + (style.linethrough ? 'line-through ' : '');
}
return '';
return ['overline', 'underline', 'line-through'].filter(function(decoration) {
return style[decoration.replace('-', '')];
}).join(' ');
},

/**
Expand Down Expand Up @@ -16410,7 +16449,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
drawBorders: function(ctx, styleOverride) {
styleOverride = styleOverride || {};
var wh = this._calculateCurrentDimensions(),
strokeWidth = 1 / this.borderScaleFactor,
strokeWidth = this.borderScaleFactor,
width = wh.x + strokeWidth,
height = wh.y + strokeWidth,
drawRotatingPoint = typeof styleOverride.hasRotatingPoint !== 'undefined' ?
Expand Down Expand Up @@ -16457,17 +16496,19 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
*/
drawBordersInGroup: function(ctx, options, styleOverride) {
styleOverride = styleOverride || {};
var p = this._getNonTransformedDimensions(),
var p = { x: this.width, y: this.height },
matrix = fabric.util.composeMatrix({
scaleX: options.scaleX,
scaleY: options.scaleY,
skewX: options.skewX
}),
wh = fabric.util.transformPoint(p, matrix),
strokeWidth = 1 / this.borderScaleFactor,
width = wh.x + strokeWidth,
height = wh.y + strokeWidth;

strokeWidth = this.strokeWidth,
borderScaleFactor = this.borderScaleFactor,
width =
wh.x + strokeWidth * (this.strokeUniform ? this.canvas.getZoom() : options.scaleX) + borderScaleFactor,
height =
wh.y + strokeWidth * (this.strokeUniform ? this.canvas.getZoom() : options.scaleY) + borderScaleFactor;
ctx.save();
this._setLineDash(ctx, styleOverride.borderDashArray || this.borderDashArray, null);
ctx.strokeStyle = styleOverride.borderColor || this.borderColor;
Expand Down Expand Up @@ -19526,8 +19567,8 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
* @return {Boolean}
*/
willDrawShadow: function() {
if (this.shadow) {
return fabric.Object.prototype.willDrawShadow.call(this);
if (fabric.Object.prototype.willDrawShadow.call(this)) {
return true;
}
for (var i = 0, len = this._objects.length; i < len; i++) {
if (this._objects[i].willDrawShadow()) {
Expand Down Expand Up @@ -27727,17 +27768,17 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
*/
exitEditing: function() {
var isTextChanged = (this._textBeforeEdit !== this.text);
var hiddenTextarea = this.hiddenTextarea;
this.selected = false;
this.isEditing = false;

this.selectionEnd = this.selectionStart;

if (this.hiddenTextarea) {
this.hiddenTextarea.blur && this.hiddenTextarea.blur();
this.canvas && this.hiddenTextarea.parentNode.removeChild(this.hiddenTextarea);
this.hiddenTextarea = null;
if (hiddenTextarea) {
hiddenTextarea.blur && hiddenTextarea.blur();
hiddenTextarea.parentNode && hiddenTextarea.parentNode.removeChild(hiddenTextarea);
}

this.hiddenTextarea = null;
this.abortCursorAnimation();
this._restoreEditingProps();
this._currentCursorOpacity = 0;
Expand Down
2 changes: 1 addition & 1 deletion dist/fabric.min.js

Large diffs are not rendered by default.

31 changes: 10 additions & 21 deletions src/mixins/animation.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
propPair = property.split('.');
}

var propIsColor = _this.colorProperties.indexOf(property) > -1 || (propPair && _this.colorProperties.indexOf(propPair[1]) > -1);

var currentValue = propPair
? this.get(propPair[0])[propPair[1]]
: this.get(property);
Expand All @@ -184,25 +182,23 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
options.from = currentValue;
}

if (!propIsColor) {
if (~to.indexOf('=')) {
to = currentValue + parseFloat(to.replace('=', ''));
}
else {
to = parseFloat(to);
}
if (~to.indexOf('=')) {
to = currentValue + parseFloat(to.replace('=', ''));
}
else {
to = parseFloat(to);
}

var _options = {
fabric.util.animate({
startValue: options.from,
endValue: to,
byValue: options.by,
easing: options.easing,
duration: options.duration,
abort: options.abort && function () {
abort: options.abort && function() {
return options.abort.call(_this);
},
onChange: function (value, valueProgress, timeProgress) {
onChange: function(value, valueProgress, timeProgress) {
if (propPair) {
_this[propPair[0]][propPair[1]] = value;
}
Expand All @@ -214,21 +210,14 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
}
options.onChange && options.onChange(value, valueProgress, timeProgress);
},
onComplete: function (value, valueProgress, timeProgress) {
onComplete: function(value, valueProgress, timeProgress) {
if (skipCallbacks) {
return;
}

_this.setCoords();
options.onComplete && options.onComplete(value, valueProgress, timeProgress);
}
};

if (propIsColor) {
fabric.util.animateColor(_options.startValue, _options.endValue, _options.duration, _options);
}
else {
fabric.util.animate(_options);
}
});
}
});
Loading

0 comments on commit c80c3e7

Please sign in to comment.