version 1.7.13 (#4008)

* Minimize delay between clear and re render. (#4007)

* moved clear later

* moved clear later

* v1713

* changed readme

* try to fix tests
This commit is contained in:
Andrea Bogazzi 2017-06-14 22:46:51 +02:00 committed by GitHub
parent e126011652
commit 17ad6c6a0a
11 changed files with 66 additions and 78 deletions

View file

@ -1,3 +1,12 @@
**Version 1.7.13**
- Fix: Try to minimize delay in loadFroJson [#4007](https://github.com/kangax/fabric.js/pull/4007)
- Fix: allow fabric.Color to parse rgba(x,y,z,.a) without leading 0 [#4006](https://github.com/kangax/fabric.js/pull/4006)
- Allow path to execute Object.initialize, make extensions easier [#4005](https://github.com/kangax/fabric.js/pull/4005)
- Fix: properly set options from path fromDatalessObjects [#3995](https://github.com/kangax/fabric.js/pull/3995)
- Check for slice before action.slice. Avoid conflicts with heavy customized code. [#3992](https://github.com/kangax/fabric.js/pull/3992)
**Version 1.7.12**
- Fix: removed possible memleaks from window resize event. [#3984](https://github.com/kangax/fabric.js/pull/3984)

View file

@ -1,6 +1,6 @@
/*! 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;
}

View file

@ -25,7 +25,7 @@ Remove the template from below and provide thoughtful commentary *and code sampl
<!-- BUG TEMPLATE -->
## Version
1.7.12
1.7.13
## Test Case
http://jsfiddle.net/fabricjs/Da7SP/

View file

@ -43,7 +43,7 @@ Fabric.js allows you to easily create simple shapes like rectangles, circles, tr
### Goals
- Unit tested (2400+ tests at the moment)
- Unit tested (4200+ tests at the moment, 75% coverage)
- Modular (~60 small ["classes", modules, mixins](http://fabricjs.com/docs/))
- Cross-browser
- [Fast](https://github.com/kangax/fabric.js/wiki/Focus-on-speed)
@ -269,11 +269,11 @@ Get help in Fabric's IRC channel — irc://irc.freenode.net/#fabric.js
### Credits
- [Andrea Bogazzi](https://twitter.com/AndreaBogazzi) for help with bugs, features, documentation, github issues, and much more.
- Ernest Delgado for the original idea of [manipulating images on canvas](http://www.ernestdelgado.com/archive/canvas/)
- [Maxim "hakunin" Chernyak](http://twitter.com/hakunin) for ideas, and help with various parts of the library throughout its life
- [Sergey Nisnevich](http://nisnya.com) for help with geometry logic
- [Stefan Kienzle](https://twitter.com/kienzle_s) for help with bugs, features, documentation, github issues
- [Andrea Bogazzi](https://twitter.com/AndreaBogazzi) for help with bugs, features, documentation, github issues, and much more.
- [And all the other GitHub contributors](https://github.com/kangax/fabric.js/graphs/contributors)
### MIT License

58
dist/fabric.js vendored
View file

@ -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);

16
dist/fabric.min.js vendored

File diff suppressed because one or more lines are too long

BIN
dist/fabric.min.js.gz vendored

Binary file not shown.

View file

@ -1,5 +1,5 @@
var fabric = fabric || {
version: "1.7.12"
version: "1.7.13"
};
if (typeof exports !== "undefined") {
@ -2751,7 +2751,7 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
return this;
}
};
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*)?\)$/;
fabric.Color.reHSLa = /^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/;
fabric.Color.reHex = /^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i;
fabric.Color.colorNameMap = {
@ -5868,23 +5868,29 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
return;
}
var serialized = typeof json === "string" ? JSON.parse(json) : fabric.util.object.clone(json);
this.clear();
var _this = this;
this._enlivenObjects(serialized.objects, function() {
var _this = this, renderOnAddRemove = this.renderOnAddRemove;
this.renderOnAddRemove = false;
this._enlivenObjects(serialized.objects, function(enlivenedObjects) {
_this.clear();
_this._setBgOverlay(serialized, function() {
enlivenedObjects.forEach(function(obj, index) {
_this.insertAt(obj, index);
});
_this.renderOnAddRemove = renderOnAddRemove;
delete serialized.objects;
delete serialized.backgroundImage;
delete serialized.overlayImage;
delete serialized.background;
delete serialized.overlay;
_this._setOptions(serialized);
_this.renderAll();
callback && callback();
});
}, reviver);
return this;
},
_setBgOverlay: function(serialized, callback) {
var _this = this, loaded = {
var loaded = {
backgroundColor: false,
overlayColor: false,
backgroundImage: false,
@ -5896,7 +5902,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
}
var cbIfLoaded = function() {
if (loaded.backgroundImage && loaded.overlayImage && loaded.backgroundColor && loaded.overlayColor) {
_this.renderAll();
callback && callback();
}
};
@ -5926,19 +5931,12 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
}
},
_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) {
_this.insertAt(obj, index);
});
_this.renderOnAddRemove = renderOnAddRemove;
callback && callback();
callback && callback(enlivenedObjects);
}, null, reviver);
},
_toDataURL: function(format, callback) {
@ -6079,7 +6077,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, {
_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;
}
}
@ -8068,9 +8066,7 @@ fabric.util.object.extend(fabric.Object.prototype, {
cacheProperties: cacheProperties,
initialize: function(path, options) {
options = options || {};
if (options) {
this.setOptions(options);
}
this.callSuper("initialize", options);
if (!path) {
path = [];
}
@ -8547,7 +8543,7 @@ fabric.util.object.extend(fabric.Object.prototype, {
var pathUrl = object.path;
path = elements[0];
delete object.path;
fabric.util.object.extend(path, object);
path.setOptions(object);
path.setSourcePath(pathUrl);
callback && callback(path);
});

View file

@ -2,7 +2,7 @@
"name": "fabric",
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
"homepage": "http://fabricjs.com/",
"version": "1.7.12",
"version": "1.7.13",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"contributors": [
{

View file

@ -179,7 +179,7 @@
var canvas = fabric.isLikelyNode ? fabric.createCanvasForNode() : new fabric.StaticCanvas(el);
var gradient = createLinearGradient();
ok(typeof gradient.toLive === 'function');
var gradientCtx = gradient.toLive(canvas.contextContainer);
var gradientCtx = gradient.toLive(canvas.contextContainer, {});
equal(gradientCtx.toString(), '[object CanvasGradient]', 'is a gradient for canvas radial');
});
@ -188,7 +188,7 @@
var canvas = fabric.isLikelyNode ? fabric.createCanvasForNode() : new fabric.StaticCanvas(el);
var gradient = createRadialGradient();
ok(typeof gradient.toLive === 'function');
var gradientCtx = gradient.toLive(canvas.contextContainer);
var gradientCtx = gradient.toLive(canvas.contextContainer, {});
equal(gradientCtx.toString(), '[object CanvasGradient]', 'is a gradient for canvas radial');
});

View file

@ -133,15 +133,6 @@
equal(camelize('--double'), 'Double');
});
test('fabric.util.string.graphemeSplit', function() {
var gSplit = fabric.util.string.graphemeSplit;
ok(typeof gSplit === 'function');
deepEqual(gSplit('foo'), ['f', 'o', 'o'], 'normal test get splitted by char');
deepEqual(gSplit('f🙂o'), ['f', '🙂', 'o'], 'normal test get splitted by char');
});
test('fabric.util.string.escapeXml', function() {
var escapeXml = fabric.util.string.escapeXml;