|
|
@@ -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.12" };
|
|
|
+var fabric = fabric || { version: "1.7.13" };
|
|
|
if (typeof exports !== 'undefined') {
|
|
|
exports.fabric = fabric;
|
|
|
}
|
|
|
@@ -5094,7 +5094,7 @@ fabric.ElementsParser.prototype.checkIfDone = function() { |
|
|
* @memberOf fabric.Color
|
|
|
*/
|
|
|
// eslint-disable-next-line max-len
|
|
|
- fabric.Color.reRGBa = /^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/;
|
|
|
+ fabric.Color.reRGBa = /^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/;
|
|
|
|
|
|
/**
|
|
|
* Regex matching color in HSL or HSLA formats (ex: hsl(200, 80%, 10%), hsla(300, 50%, 80%, 0.5), hsla( 300 , 50% , 80% , 0.5 ))
|
|
|
@@ -11489,11 +11489,19 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati |
|
|
? JSON.parse(json)
|
|
|
: fabric.util.object.clone(json);
|
|
|
|
|
|
- this.clear();
|
|
|
+ var _this = this,
|
|
|
+ renderOnAddRemove = this.renderOnAddRemove;
|
|
|
+ this.renderOnAddRemove = false;
|
|
|
|
|
|
- var _this = this;
|
|
|
- this._enlivenObjects(serialized.objects, function () {
|
|
|
+ this._enlivenObjects(serialized.objects, function (enlivenedObjects) {
|
|
|
+ _this.clear();
|
|
|
_this._setBgOverlay(serialized, function () {
|
|
|
+ enlivenedObjects.forEach(function(obj, index) {
|
|
|
+ // we splice the array just in case some custom classes restored from JSON
|
|
|
+ // will add more object to canvas at canvas init.
|
|
|
+ _this.insertAt(obj, index);
|
|
|
+ });
|
|
|
+ _this.renderOnAddRemove = renderOnAddRemove;
|
|
|
// remove parts i cannot set as options
|
|
|
delete serialized.objects;
|
|
|
delete serialized.backgroundImage;
|
|
|
@@ -11505,6 +11513,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati |
|
|
// create the Object instance. Here the Canvas is
|
|
|
// already an instance and we are just loading things over it
|
|
|
_this._setOptions(serialized);
|
|
|
+ _this.renderAll();
|
|
|
callback && callback();
|
|
|
});
|
|
|
}, reviver);
|
|
|
@@ -11517,13 +11526,12 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati |
|
|
* @param {Function} callback Invoked after all background and overlay images/patterns loaded
|
|
|
*/
|
|
|
_setBgOverlay: function(serialized, callback) {
|
|
|
- var _this = this,
|
|
|
- loaded = {
|
|
|
- backgroundColor: false,
|
|
|
- overlayColor: false,
|
|
|
- backgroundImage: false,
|
|
|
- overlayImage: false
|
|
|
- };
|
|
|
+ var loaded = {
|
|
|
+ backgroundColor: false,
|
|
|
+ overlayColor: false,
|
|
|
+ backgroundImage: false,
|
|
|
+ overlayImage: false
|
|
|
+ };
|
|
|
|
|
|
if (!serialized.backgroundImage && !serialized.overlayImage && !serialized.background && !serialized.overlay) {
|
|
|
callback && callback();
|
|
|
@@ -11532,7 +11540,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati |
|
|
|
|
|
var cbIfLoaded = function () {
|
|
|
if (loaded.backgroundImage && loaded.overlayImage && loaded.backgroundColor && loaded.overlayColor) {
|
|
|
- _this.renderAll();
|
|
|
callback && callback();
|
|
|
}
|
|
|
};
|
|
|
@@ -11581,25 +11588,13 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati |
|
|
* @param {Function} [reviver]
|
|
|
*/
|
|
|
_enlivenObjects: function (objects, callback, reviver) {
|
|
|
- var _this = this;
|
|
|
-
|
|
|
if (!objects || objects.length === 0) {
|
|
|
- callback && callback();
|
|
|
+ callback && callback([]);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- var renderOnAddRemove = this.renderOnAddRemove;
|
|
|
- this.renderOnAddRemove = false;
|
|
|
-
|
|
|
fabric.util.enlivenObjects(objects, function(enlivenedObjects) {
|
|
|
- enlivenedObjects.forEach(function(obj, index) {
|
|
|
- // we splice the array just in case some custom classes restored from JSON
|
|
|
- // will add more object to canvas at canvas init.
|
|
|
- _this.insertAt(obj, index);
|
|
|
- });
|
|
|
-
|
|
|
- _this.renderOnAddRemove = renderOnAddRemove;
|
|
|
- callback && callback();
|
|
|
+ callback && callback(enlivenedObjects);
|
|
|
}, null, reviver);
|
|
|
},
|
|
|
|
|
|
@@ -12546,7 +12541,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati |
|
|
_updateCacheCanvas: function() {
|
|
|
if (this.noScaleCache && this.canvas && this.canvas._currentTransform) {
|
|
|
var action = this.canvas._currentTransform.action;
|
|
|
- if (action.slice(0, 5) === 'scale') {
|
|
|
+ if (action.slice && action.slice(0, 5) === 'scale') {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
@@ -16928,10 +16923,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot |
|
|
*/
|
|
|
initialize: function(path, options) {
|
|
|
options = options || { };
|
|
|
-
|
|
|
- if (options) {
|
|
|
- this.setOptions(options);
|
|
|
- }
|
|
|
+ this.callSuper('initialize', options);
|
|
|
|
|
|
if (!path) {
|
|
|
path = [];
|
|
|
@@ -17776,7 +17768,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot |
|
|
path = elements[0];
|
|
|
delete object.path;
|
|
|
|
|
|
- fabric.util.object.extend(path, object);
|
|
|
+ path.setOptions(object);
|
|
|
path.setSourcePath(pathUrl);
|
|
|
|
|
|
callback && callback(path);
|
0 comments on commit
17ad6c6