Skip to content

Commit

Permalink
v1717 (#4122)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Jul 22, 2017
1 parent 213c945 commit 7cc16fb
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 49 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
**Version 1.7.17**

- Change: swapped style white-space:nowrap with attribute wrap="off" since the style rule was creating problems in browsers like ie11 and safari. [#4119](https://github.com/kangax/fabric.js/pull/4119)
- Fix: Remove an object from activeGroup if removed from canvas [#4120](https://github.com/kangax/fabric.js/pull/4120)
- Fix: avoid bringFroward, sendBackwards to swap objects in active selections [#4119](https://github.com/kangax/fabric.js/pull/4119)
- Fix: avoid disposing canvas on mouse event to throw error [#4119](https://github.com/kangax/fabric.js/pull/4119)
- Fix: make svg respect white spaces [#4119](https://github.com/kangax/fabric.js/pull/4119)
- Fix: avoid exporting bgImage and overlayImage if excludeFromExport = true [#4119](https://github.com/kangax/fabric.js/pull/4119)
- Fix: Avoid group fromObject mutating original data [#4111](https://github.com/kangax/fabric.js/pull/4111)

**Version 1.7.16**

- Improvement: Add information to onChange and onComplete animation function [#4068](https://github.com/kangax/fabric.js/pull/4068)
Expand Down
2 changes: 1 addition & 1 deletion HEADER.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */

var fabric = fabric || { version: "1.7.16" };
var fabric = fabric || { version: "1.7.17" };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}
Expand Down
73 changes: 53 additions & 20 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=json,gestures minifier=uglifyjs` */
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */

var fabric = fabric || { version: "1.7.16" };
var fabric = fabric || { version: "1.7.17" };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}
Expand Down Expand Up @@ -2112,17 +2112,20 @@ fabric.CommonMethods = {
/** @ignore */
addListener = function (element, eventName, handler, options) {
// since ie10 or ie9 can use addEventListener but they do not support options, i need to check
element.addEventListener(eventName, handler, shouldUseAttachEventDetachEvent ? false : options);
element && element.addEventListener(eventName, handler, shouldUseAttachEventDetachEvent ? false : options);
};
/** @ignore */
removeListener = function (element, eventName, handler, options) {
element.removeEventListener(eventName, handler, shouldUseAttachEventDetachEvent ? false : options);
element && element.removeEventListener(eventName, handler, shouldUseAttachEventDetachEvent ? false : options);
};
}

else if (shouldUseAttachEventDetachEvent) {
/** @ignore */
addListener = function (element, eventName, handler) {
if (!element) {
return;
}
var uid = getUniqueId(element);
setElement(uid, element);
if (!listeners[uid]) {
Expand All @@ -2138,6 +2141,9 @@ fabric.CommonMethods = {
};
/** @ignore */
removeListener = function (element, eventName, handler) {
if (!element) {
return;
}
var uid = getUniqueId(element), listener;
if (listeners[uid] && listeners[uid][eventName]) {
for (var i = 0, len = listeners[uid][eventName].length; i < len; i++) {
Expand All @@ -2153,6 +2159,9 @@ fabric.CommonMethods = {
else {
/** @ignore */
addListener = function (element, eventName, handler) {
if (!element) {
return;
}
var uid = getUniqueId(element);
if (!handlers[uid]) {
handlers[uid] = { };
Expand All @@ -2169,6 +2178,9 @@ fabric.CommonMethods = {
};
/** @ignore */
removeListener = function (element, eventName, handler) {
if (!element) {
return;
}
var uid = getUniqueId(element);
if (handlers[uid] && handlers[uid][eventName]) {
var handlersForEvent = handlers[uid][eventName];
Expand Down Expand Up @@ -7303,7 +7315,7 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
* @private
*/
__serializeBgOverlay: function(methodName, propertiesToInclude) {
var data = { };
var data = { }, bgImage = this.backgroundImage, overlay = this.overlayImage;

if (this.backgroundColor) {
data.background = this.backgroundColor.toObject
Expand All @@ -7316,11 +7328,11 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
? this.overlayColor.toObject(propertiesToInclude)
: this.overlayColor;
}
if (this.backgroundImage) {
data.backgroundImage = this._toObject(this.backgroundImage, methodName, propertiesToInclude);
if (bgImage && !bgImage.excludeFromExport) {
data.backgroundImage = this._toObject(bgImage, methodName, propertiesToInclude);
}
if (this.overlayImage) {
data.overlayImage = this._toObject(this.overlayImage, methodName, propertiesToInclude);
if (overlay && !overlay.excludeFromExport) {
data.overlayImage = this._toObject(overlay, methodName, propertiesToInclude);
}

return data;
Expand Down Expand Up @@ -7658,19 +7670,21 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
if (!object) {
return this;
}

var activeGroup = this._activeGroup,
i, obj, idx, newIdx, objs;
i, obj, idx, newIdx, objs, objsMoved = 0;

if (object === activeGroup) {
objs = activeGroup._objects;
for (i = 0; i < objs.length; i++) {
obj = objs[i];
idx = this._objects.indexOf(obj);
if (idx !== 0) {
if (idx > 0 + objsMoved) {
newIdx = idx - 1;
removeFromArray(this._objects, obj);
this._objects.splice(newIdx, 0, obj);
}
objsMoved++;
}
}
else {
Expand Down Expand Up @@ -7726,19 +7740,21 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
if (!object) {
return this;
}

var activeGroup = this._activeGroup,
i, obj, idx, newIdx, objs;
i, obj, idx, newIdx, objs, objsMoved = 0;

if (object === activeGroup) {
objs = activeGroup._objects;
for (i = objs.length; i--;) {
obj = objs[i];
idx = this._objects.indexOf(obj);
if (idx !== this._objects.length - 1) {
if (idx < this._objects.length - 1 - objsMoved) {
newIdx = idx + 1;
removeFromArray(this._objects, obj);
this._objects.splice(newIdx, 0, obj);
}
objsMoved++;
}
}
else {
Expand Down Expand Up @@ -10187,7 +10203,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab
* @chainable
*/
dispose: function () {
this.callSuper('dispose');
fabric.StaticCanvas.prototype.dispose.call(this);
var wrapper = this.wrapperEl;
this.removeListeners();
wrapper.removeChild(this.upperCanvasEl);
Expand Down Expand Up @@ -13578,7 +13594,12 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
* @chainable
*/
remove: function() {
this.canvas && this.canvas.remove(this);
if (this.canvas) {
if (this.group && this.group === this.canvas._activeGroup) {
this.group.remove(this);
}
this.canvas.remove(this);
}
return this;
},

Expand Down Expand Up @@ -18930,8 +18951,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
*/
fabric.Group.fromObject = function(object, callback) {
fabric.util.enlivenObjects(object.objects, function(enlivenedObjects) {
delete object.objects;
callback && callback(new fabric.Group(enlivenedObjects, object, true));
var options = fabric.util.object.clone(object, true);
delete options.objects;
callback && callback(new fabric.Group(enlivenedObjects, options, true));
});
};

Expand Down Expand Up @@ -22759,7 +22781,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
'\t<g ', this.getSvgId(), 'transform="', this.getSvgTransform(), this.getSvgTransformMatrix(), '"',
style, '>\n',
textAndBg.textBgRects.join(''),
'\t\t<text ',
'\t\t<text xml:space="preserve" ',
(this.fontFamily ? 'font-family="' + this.fontFamily.replace(/"/g, '\'') + '" ' : ''),
(this.fontSize ? 'font-size="' + this.fontSize + '" ' : ''),
(this.fontStyle ? 'font-style="' + this.fontStyle + '" ' : ''),
Expand All @@ -22772,6 +22794,11 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
);
},

getSvgStyles: function(skipShadow) {
var svgStyle = fabric.Object.prototype.getSvgStyles.call(this, skipShadow);
return svgStyle + ' white-space: pre;';
},

/**
* @private
* @param {Number} textTopOffset Text top offset
Expand Down Expand Up @@ -25390,9 +25417,15 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
initHiddenTextarea: function() {
this.hiddenTextarea = fabric.document.createElement('textarea');
this.hiddenTextarea.setAttribute('autocapitalize', 'off');
this.hiddenTextarea.setAttribute('autocorrect', 'off');
this.hiddenTextarea.setAttribute('autocomplete', 'off');
this.hiddenTextarea.setAttribute('spellcheck', 'false');
this.hiddenTextarea.setAttribute('data-fabric-hiddentextarea', '');
this.hiddenTextarea.setAttribute('wrap', 'off');
var style = this._calcTextareaPosition();
this.hiddenTextarea.style.cssText = 'white-space: nowrap; position: absolute; top: ' + style.top +
'; left: ' + style.left + '; opacity: 0; width: 1px; height: 1px; z-index: -999;';
this.hiddenTextarea.style.cssText = 'position: absolute; top: ' + style.top +
'; left: ' + style.left + '; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px;' +
' line-height: 1px; paddingーtop: ' + style.fontSize + ';';
fabric.document.body.appendChild(this.hiddenTextarea);

fabric.util.addListener(this.hiddenTextarea, 'keydown', this.onKeyDown.bind(this));
Expand Down Expand Up @@ -26155,7 +26188,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
fabric.util.string.escapeXml(_char),
'</tspan>\n'
].join('');
}
},
});
})();
/* _TO_SVG_END_ */
Expand Down
18 changes: 9 additions & 9 deletions dist/fabric.min.js

Large diffs are not rendered by default.

Binary file modified dist/fabric.min.js.gz
Binary file not shown.
Loading

0 comments on commit 7cc16fb

Please sign in to comment.