mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-16 22:10:32 +00:00
built 2.3.5 (#5166)
This commit is contained in:
parent
e5e4387915
commit
e09d6dbe72
7 changed files with 95 additions and 91 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
**Version 2.3.5**
|
||||||
|
- Change: make canvas.getObjects() always return a shallow copy of the array [#5162](https://github.com/fabricjs/fabric.js/pull/5162)
|
||||||
|
- Fix: Improve fabric.Pattern.toSVG to look correct on offsets and no-repeat [#5164](https://github.com/fabricjs/fabric.js/pull/5164)
|
||||||
|
- Fix: Do not enter edit in Itext if the mouseUp is relative to a group selector [#5153](https://github.com/fabricjs/fabric.js/pull/5153)
|
||||||
|
- Improvement: Do not require xlink namespace in front of href attribut for svgs ( is a SVG2 new spec, unsupported ) [#5156](https://github.com/fabricjs/fabric.js/pull/5156)
|
||||||
|
- Fix: fix resizeFilter having the wrong cached texture, also improved interaction between filters [#5165](https://github.com/fabricjs/fabric.js/pull/5165)
|
||||||
|
|
||||||
**Version 2.3.4**
|
**Version 2.3.4**
|
||||||
- Fix: ToSVG was ignoring excludeFromExport for backgroundImage and OverlayImage. [#5075](https://github.com/fabricjs/fabric.js/pull/5075)
|
- Fix: ToSVG was ignoring excludeFromExport for backgroundImage and OverlayImage. [#5075](https://github.com/fabricjs/fabric.js/pull/5075)
|
||||||
- Fix: ToSVG for circle with start and end angles. [#5085](https://github.com/fabricjs/fabric.js/pull/5085)
|
- Fix: ToSVG for circle with start and end angles. [#5085](https://github.com/fabricjs/fabric.js/pull/5085)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
||||||
|
|
||||||
var fabric = fabric || { version: '2.3.4' };
|
var fabric = fabric || { version: '2.3.5' };
|
||||||
if (typeof exports !== 'undefined') {
|
if (typeof exports !== 'undefined') {
|
||||||
exports.fabric = fabric;
|
exports.fabric = fabric;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ Remove the template from below and provide thoughtful commentary *and code sampl
|
||||||
|
|
||||||
<!-- BUG TEMPLATE -->
|
<!-- BUG TEMPLATE -->
|
||||||
## Version
|
## Version
|
||||||
2.3.0
|
2.3.5
|
||||||
|
|
||||||
## Test Case
|
## Test Case
|
||||||
http://jsfiddle.net/fabricjs/Da7SP/
|
http://jsfiddle.net/fabricjs/Da7SP/
|
||||||
|
|
|
||||||
|
|
@ -42,14 +42,14 @@ Fabric.js allows you to easily create simple shapes like rectangles, circles, tr
|
||||||
|
|
||||||
### Goals
|
### Goals
|
||||||
|
|
||||||
- Unit tested (4800+ assertion, 1050+ tests at the moment, 76%+ coverage)
|
- Unit tested (1150+ tests at the moment, 79%+ coverage)
|
||||||
- Modular (~60 small ["classes", modules, mixins](http://fabricjs.com/docs/))
|
- Modular (~60 small ["classes", modules, mixins](http://fabricjs.com/docs/))
|
||||||
- Cross-browser
|
- Cross-browser
|
||||||
- [Fast](https://github.com/kangax/fabric.js/wiki/Focus-on-speed)
|
- [Fast](https://github.com/kangax/fabric.js/wiki/Focus-on-speed)
|
||||||
- Encapsulated in one object
|
- Encapsulated in one object
|
||||||
- No browser sniffing for critical functionality
|
- No browser sniffing for critical functionality
|
||||||
- Runs under ES5 strict mode
|
- Runs under ES5 strict mode
|
||||||
- Runs on a server under [Node.js](http://nodejs.org/) (stable releases and latest of current) (see [Node.js limitations](https://github.com/kangax/fabric.js/wiki/Fabric-limitations-in-node.js))
|
- Runs on a server under [Node.js](http://nodejs.org/) (active stable releases and latest of current) (see [Node.js limitations](https://github.com/kangax/fabric.js/wiki/Fabric-limitations-in-node.js))
|
||||||
- Follows [Semantic Versioning](http://semver.org/)
|
- Follows [Semantic Versioning](http://semver.org/)
|
||||||
|
|
||||||
### Supported browsers
|
### Supported browsers
|
||||||
|
|
|
||||||
167
dist/fabric.js
vendored
167
dist/fabric.js
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
/* build: `node build.js modules=ALL exclude=gestures,accessors requirejs minifier=uglifyjs` */
|
/* build: `node build.js modules=ALL exclude=gestures,accessors requirejs minifier=uglifyjs` */
|
||||||
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
||||||
|
|
||||||
var fabric = fabric || { version: '2.3.4' };
|
var fabric = fabric || { version: '2.3.5' };
|
||||||
if (typeof exports !== 'undefined') {
|
if (typeof exports !== 'undefined') {
|
||||||
exports.fabric = fabric;
|
exports.fabric = fabric;
|
||||||
}
|
}
|
||||||
|
|
@ -352,7 +352,7 @@ fabric.Collection = {
|
||||||
* @chainable
|
* @chainable
|
||||||
*/
|
*/
|
||||||
insertAt: function (object, index, nonSplicing) {
|
insertAt: function (object, index, nonSplicing) {
|
||||||
var objects = this.getObjects();
|
var objects = this._objects;
|
||||||
if (nonSplicing) {
|
if (nonSplicing) {
|
||||||
objects[index] = object;
|
objects[index] = object;
|
||||||
}
|
}
|
||||||
|
|
@ -371,7 +371,7 @@ fabric.Collection = {
|
||||||
* @chainable
|
* @chainable
|
||||||
*/
|
*/
|
||||||
remove: function() {
|
remove: function() {
|
||||||
var objects = this.getObjects(),
|
var objects = this._objects,
|
||||||
index, somethingRemoved = false;
|
index, somethingRemoved = false;
|
||||||
|
|
||||||
for (var i = 0, length = arguments.length; i < length; i++) {
|
for (var i = 0, length = arguments.length; i < length; i++) {
|
||||||
|
|
@ -412,12 +412,13 @@ fabric.Collection = {
|
||||||
/**
|
/**
|
||||||
* Returns an array of children objects of this instance
|
* Returns an array of children objects of this instance
|
||||||
* Type parameter introduced in 1.3.10
|
* Type parameter introduced in 1.3.10
|
||||||
|
* since 2.3.5 this method return always a COPY of the array;
|
||||||
* @param {String} [type] When specified, only objects of this type are returned
|
* @param {String} [type] When specified, only objects of this type are returned
|
||||||
* @return {Array}
|
* @return {Array}
|
||||||
*/
|
*/
|
||||||
getObjects: function(type) {
|
getObjects: function(type) {
|
||||||
if (typeof type === 'undefined') {
|
if (typeof type === 'undefined') {
|
||||||
return this._objects;
|
return this._objects.concat();
|
||||||
}
|
}
|
||||||
return this._objects.filter(function(o) {
|
return this._objects.filter(function(o) {
|
||||||
return o.type === type;
|
return o.type === type;
|
||||||
|
|
@ -430,7 +431,7 @@ fabric.Collection = {
|
||||||
* @return {Self} thisArg
|
* @return {Self} thisArg
|
||||||
*/
|
*/
|
||||||
item: function (index) {
|
item: function (index) {
|
||||||
return this.getObjects()[index];
|
return this._objects[index];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -438,7 +439,7 @@ fabric.Collection = {
|
||||||
* @return {Boolean} true if collection is empty
|
* @return {Boolean} true if collection is empty
|
||||||
*/
|
*/
|
||||||
isEmpty: function () {
|
isEmpty: function () {
|
||||||
return this.getObjects().length === 0;
|
return this._objects.length === 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -446,7 +447,7 @@ fabric.Collection = {
|
||||||
* @return {Number} Collection size
|
* @return {Number} Collection size
|
||||||
*/
|
*/
|
||||||
size: function() {
|
size: function() {
|
||||||
return this.getObjects().length;
|
return this._objects.length;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -455,7 +456,7 @@ fabric.Collection = {
|
||||||
* @return {Boolean} `true` if collection contains an object
|
* @return {Boolean} `true` if collection contains an object
|
||||||
*/
|
*/
|
||||||
contains: function(object) {
|
contains: function(object) {
|
||||||
return this.getObjects().indexOf(object) > -1;
|
return this._objects.indexOf(object) > -1;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -463,7 +464,7 @@ fabric.Collection = {
|
||||||
* @return {Number} complexity
|
* @return {Number} complexity
|
||||||
*/
|
*/
|
||||||
complexity: function () {
|
complexity: function () {
|
||||||
return this.getObjects().reduce(function (memo, current) {
|
return this._objects.reduce(function (memo, current) {
|
||||||
memo += current.complexity ? current.complexity() : 0;
|
memo += current.complexity ? current.complexity() : 0;
|
||||||
return memo;
|
return memo;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
@ -3808,7 +3809,7 @@ if (typeof console !== 'undefined') {
|
||||||
|
|
||||||
while (nodelist.length && i < nodelist.length) {
|
while (nodelist.length && i < nodelist.length) {
|
||||||
var el = nodelist[i],
|
var el = nodelist[i],
|
||||||
xlink = el.getAttribute('xlink:href').substr(1),
|
xlink = (el.getAttribute('xlink:href') || el.getAttribute('href')).substr(1),
|
||||||
x = el.getAttribute('x') || 0,
|
x = el.getAttribute('x') || 0,
|
||||||
y = el.getAttribute('y') || 0,
|
y = el.getAttribute('y') || 0,
|
||||||
el2 = elementById(doc, xlink).cloneNode(true),
|
el2 = elementById(doc, xlink).cloneNode(true),
|
||||||
|
|
@ -3831,7 +3832,8 @@ if (typeof console !== 'undefined') {
|
||||||
|
|
||||||
for (j = 0, attrs = el.attributes, len = attrs.length; j < len; j++) {
|
for (j = 0, attrs = el.attributes, len = attrs.length; j < len; j++) {
|
||||||
attr = attrs.item(j);
|
attr = attrs.item(j);
|
||||||
if (attr.nodeName === 'x' || attr.nodeName === 'y' || attr.nodeName === 'xlink:href') {
|
if (attr.nodeName === 'x' || attr.nodeName === 'y' ||
|
||||||
|
attr.nodeName === 'xlink:href' || attr.nodeName === 'href') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6206,9 +6208,16 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
|
||||||
patternImgSrc = '';
|
patternImgSrc = '';
|
||||||
if (this.repeat === 'repeat-x' || this.repeat === 'no-repeat') {
|
if (this.repeat === 'repeat-x' || this.repeat === 'no-repeat') {
|
||||||
patternHeight = 1;
|
patternHeight = 1;
|
||||||
|
if (patternOffsetY) {
|
||||||
|
patternHeight += Math.abs(patternOffsetY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (this.repeat === 'repeat-y' || this.repeat === 'no-repeat') {
|
if (this.repeat === 'repeat-y' || this.repeat === 'no-repeat') {
|
||||||
patternWidth = 1;
|
patternWidth = 1;
|
||||||
|
if (patternOffsetX) {
|
||||||
|
patternWidth += Math.abs(patternOffsetX);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (patternSource.src) {
|
if (patternSource.src) {
|
||||||
patternImgSrc = patternSource.src;
|
patternImgSrc = patternSource.src;
|
||||||
|
|
@ -7292,6 +7301,10 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
|
||||||
/**
|
/**
|
||||||
* Function created to be instance bound at initialization
|
* Function created to be instance bound at initialization
|
||||||
* used in requestAnimationFrame rendering
|
* used in requestAnimationFrame rendering
|
||||||
|
* Let the fabricJS call it. If you call it manually you could have more
|
||||||
|
* animationFrame stacking on to of each other
|
||||||
|
* for an imperative rendering, use canvas.renderAll
|
||||||
|
* @private
|
||||||
* @return {fabric.Canvas} instance
|
* @return {fabric.Canvas} instance
|
||||||
* @chainable
|
* @chainable
|
||||||
*/
|
*/
|
||||||
|
|
@ -7302,6 +7315,7 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append a renderAll request to next animation frame.
|
* Append a renderAll request to next animation frame.
|
||||||
|
* unless one is already in progress, in that case nothing is done
|
||||||
* a boolean flag will avoid appending more.
|
* a boolean flag will avoid appending more.
|
||||||
* @return {fabric.Canvas} instance
|
* @return {fabric.Canvas} instance
|
||||||
* @chainable
|
* @chainable
|
||||||
|
|
@ -7331,6 +7345,13 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
|
||||||
return points;
|
return points;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cancelRequestedRender: function() {
|
||||||
|
if (this.isRendering) {
|
||||||
|
fabric.util.cancelAnimFrame(this.isRendering);
|
||||||
|
this.isRendering = 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders background, objects, overlay and controls.
|
* Renders background, objects, overlay and controls.
|
||||||
* @param {CanvasRenderingContext2D} ctx
|
* @param {CanvasRenderingContext2D} ctx
|
||||||
|
|
@ -7340,10 +7361,7 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
|
||||||
*/
|
*/
|
||||||
renderCanvas: function(ctx, objects) {
|
renderCanvas: function(ctx, objects) {
|
||||||
var v = this.viewportTransform;
|
var v = this.viewportTransform;
|
||||||
if (this.isRendering) {
|
this.cancelRequestedRender();
|
||||||
fabric.util.cancelAnimFrame(this.isRendering);
|
|
||||||
this.isRendering = 0;
|
|
||||||
}
|
|
||||||
this.calcViewportBoundaries();
|
this.calcViewportBoundaries();
|
||||||
this.clearContext(ctx);
|
this.clearContext(ctx);
|
||||||
this.fire('before:render');
|
this.fire('before:render');
|
||||||
|
|
@ -7580,7 +7598,7 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_toObjects: function(methodName, propertiesToInclude) {
|
_toObjects: function(methodName, propertiesToInclude) {
|
||||||
return this.getObjects().filter(function(object) {
|
return this._objects.filter(function(object) {
|
||||||
return !object.excludeFromExport;
|
return !object.excludeFromExport;
|
||||||
}).map(function(instance) {
|
}).map(function(instance) {
|
||||||
return this._toObject(instance, methodName, propertiesToInclude);
|
return this._toObject(instance, methodName, propertiesToInclude);
|
||||||
|
|
@ -7782,7 +7800,7 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
|
||||||
createSVGFontFacesMarkup: function() {
|
createSVGFontFacesMarkup: function() {
|
||||||
var markup = '', fontList = { }, obj, fontFamily,
|
var markup = '', fontList = { }, obj, fontFamily,
|
||||||
style, row, rowIndex, _char, charIndex, i, len,
|
style, row, rowIndex, _char, charIndex, i, len,
|
||||||
fontPaths = fabric.fontPaths, objects = this.getObjects();
|
fontPaths = fabric.fontPaths, objects = this._objects;
|
||||||
|
|
||||||
for (i = 0, len = objects.length; i < len; i++) {
|
for (i = 0, len = objects.length; i < len; i++) {
|
||||||
obj = objects[i];
|
obj = objects[i];
|
||||||
|
|
@ -7833,7 +7851,7 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_setSVGObjects: function(markup, reviver) {
|
_setSVGObjects: function(markup, reviver) {
|
||||||
var instance, i, len, objects = this.getObjects();
|
var instance, i, len, objects = this._objects;
|
||||||
for (i = 0, len = objects.length; i < len; i++) {
|
for (i = 0, len = objects.length; i < len; i++) {
|
||||||
instance = objects[i];
|
instance = objects[i];
|
||||||
if (instance.excludeFromExport) {
|
if (instance.excludeFromExport) {
|
||||||
|
|
@ -8148,7 +8166,7 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
|
||||||
*/
|
*/
|
||||||
toString: function () {
|
toString: function () {
|
||||||
return '#<fabric.Canvas (' + this.complexity() + '): ' +
|
return '#<fabric.Canvas (' + this.complexity() + '): ' +
|
||||||
'{ objects: ' + this.getObjects().length + ' }>';
|
'{ objects: ' + this._objects.length + ' }>';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -11812,7 +11830,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab
|
||||||
* @param {Object} target
|
* @param {Object} target
|
||||||
*/
|
*/
|
||||||
_createGroup: function(target) {
|
_createGroup: function(target) {
|
||||||
var objects = this.getObjects(),
|
var objects = this._objects,
|
||||||
isActiveLower = objects.indexOf(this._activeObject) < objects.indexOf(target),
|
isActiveLower = objects.indexOf(this._activeObject) < objects.indexOf(target),
|
||||||
groupObjects = isActiveLower
|
groupObjects = isActiveLower
|
||||||
? [this._activeObject, target]
|
? [this._activeObject, target]
|
||||||
|
|
@ -18364,7 +18382,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var fabric = global.fabric || (global.fabric = { }),
|
var fabric = global.fabric || (global.fabric = { }),
|
||||||
extend = fabric.util.object.extend,
|
|
||||||
min = fabric.util.array.min,
|
min = fabric.util.array.min,
|
||||||
max = fabric.util.array.max;
|
max = fabric.util.array.max;
|
||||||
|
|
||||||
|
|
@ -18569,12 +18586,11 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (key === 'canvas') {
|
if (key === 'canvas') {
|
||||||
i = this._objects.length;
|
|
||||||
while (i--) {
|
while (i--) {
|
||||||
this._objects[i]._set(key, value);
|
this._objects[i]._set(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.callSuper('_set', key, value);
|
fabric.Object.prototype._set.call(this, key, value);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -18583,16 +18599,16 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
* @return {Object} object representation of an instance
|
* @return {Object} object representation of an instance
|
||||||
*/
|
*/
|
||||||
toObject: function(propertiesToInclude) {
|
toObject: function(propertiesToInclude) {
|
||||||
var objsToObject = this.getObjects().map(function(obj) {
|
var objsToObject = this._objects.map(function(obj) {
|
||||||
var originalDefaults = obj.includeDefaultValues;
|
var originalDefaults = obj.includeDefaultValues;
|
||||||
obj.includeDefaultValues = obj.group.includeDefaultValues;
|
obj.includeDefaultValues = obj.group.includeDefaultValues;
|
||||||
var _obj = obj.toObject(propertiesToInclude);
|
var _obj = obj.toObject(propertiesToInclude);
|
||||||
obj.includeDefaultValues = originalDefaults;
|
obj.includeDefaultValues = originalDefaults;
|
||||||
return _obj;
|
return _obj;
|
||||||
});
|
});
|
||||||
return extend(this.callSuper('toObject', propertiesToInclude), {
|
var obj = fabric.Object.prototype.toObject.call(this, propertiesToInclude);
|
||||||
objects: objsToObject
|
obj.objects = objsToObject;
|
||||||
});
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -18606,7 +18622,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
objsToObject = sourcePath;
|
objsToObject = sourcePath;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
objsToObject = this.getObjects().map(function(obj) {
|
objsToObject = this._objects.map(function(obj) {
|
||||||
var originalDefaults = obj.includeDefaultValues;
|
var originalDefaults = obj.includeDefaultValues;
|
||||||
obj.includeDefaultValues = obj.group.includeDefaultValues;
|
obj.includeDefaultValues = obj.group.includeDefaultValues;
|
||||||
var _obj = obj.toDatalessObject(propertiesToInclude);
|
var _obj = obj.toDatalessObject(propertiesToInclude);
|
||||||
|
|
@ -18614,9 +18630,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
return _obj;
|
return _obj;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return extend(this.callSuper('toDatalessObject', propertiesToInclude), {
|
var obj = fabric.Object.prototype.toDatalessObject.call(this, propertiesToInclude);
|
||||||
objects: objsToObject
|
obj.objects = objsToObject;
|
||||||
});
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -18657,7 +18673,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
*/
|
*/
|
||||||
willDrawShadow: function() {
|
willDrawShadow: function() {
|
||||||
if (this.shadow) {
|
if (this.shadow) {
|
||||||
return this.callSuper('willDrawShadow');
|
return fabric.Object.prototype.willDrawShadow.call(this);
|
||||||
}
|
}
|
||||||
for (var i = 0, len = this._objects.length; i < len; i++) {
|
for (var i = 0, len = this._objects.length; i < len; i++) {
|
||||||
if (this._objects[i].willDrawShadow()) {
|
if (this._objects[i].willDrawShadow()) {
|
||||||
|
|
@ -18968,16 +18984,15 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
* @return {fabric.Group}
|
* @return {fabric.Group}
|
||||||
*/
|
*/
|
||||||
toGroup: function() {
|
toGroup: function() {
|
||||||
var objects = this._objects;
|
var objects = this._objects.concat();
|
||||||
this._objects = [];
|
this._objects = [];
|
||||||
var options = this.toObject();
|
var options = fabric.Object.prototype.toObject.call(this);
|
||||||
var newGroup = new fabric.Group([]);
|
var newGroup = new fabric.Group([]);
|
||||||
delete options.objects;
|
delete options.type;
|
||||||
newGroup.set(options);
|
newGroup.set(options);
|
||||||
newGroup.type = 'group';
|
|
||||||
objects.forEach(function(object) {
|
objects.forEach(function(object) {
|
||||||
object.group = newGroup;
|
|
||||||
object.canvas.remove(object);
|
object.canvas.remove(object);
|
||||||
|
object.group = newGroup;
|
||||||
});
|
});
|
||||||
newGroup._objects = objects;
|
newGroup._objects = objects;
|
||||||
if (!this.canvas) {
|
if (!this.canvas) {
|
||||||
|
|
@ -19008,24 +19023,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
return '#<fabric.ActiveSelection: (' + this.complexity() + ')>';
|
return '#<fabric.ActiveSelection: (' + this.complexity() + ')>';
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
_set: function(key, value) {
|
|
||||||
var i = this._objects.length;
|
|
||||||
if (key === 'canvas') {
|
|
||||||
while (i--) {
|
|
||||||
this._objects[i].set(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.useSetOnGroup) {
|
|
||||||
while (i--) {
|
|
||||||
this._objects[i].setOnGroup(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fabric.Object.prototype._set.call(this, key, value);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decide if the object should cache or not. Create its own cache level
|
* Decide if the object should cache or not. Create its own cache level
|
||||||
* objectCaching is a global flag, wins over everything
|
* objectCaching is a global flag, wins over everything
|
||||||
|
|
@ -19038,22 +19035,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if this object or a child object will cast a shadow
|
|
||||||
* @return {Boolean}
|
|
||||||
*/
|
|
||||||
willDrawShadow: function() {
|
|
||||||
if (this.shadow) {
|
|
||||||
return this.callSuper('willDrawShadow');
|
|
||||||
}
|
|
||||||
for (var i = 0, len = this._objects.length; i < len; i++) {
|
|
||||||
if (this._objects[i].willDrawShadow()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this group or its parent group are caching, recursively up
|
* Check if this group or its parent group are caching, recursively up
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
|
|
@ -19263,11 +19244,8 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
* @chainable
|
* @chainable
|
||||||
*/
|
*/
|
||||||
setElement: function(element, options) {
|
setElement: function(element, options) {
|
||||||
var backend = fabric.filterBackend;
|
this.removeTexture(this.cacheKey);
|
||||||
if (backend && backend.evictCachesForKey) {
|
this.removeTexture(this.cacheKey + '_filtered');
|
||||||
backend.evictCachesForKey(this.cacheKey);
|
|
||||||
backend.evictCachesForKey(this.cacheKey + '_filtered');
|
|
||||||
}
|
|
||||||
this._element = element;
|
this._element = element;
|
||||||
this._originalElement = element;
|
this._originalElement = element;
|
||||||
this._initConfig(options);
|
this._initConfig(options);
|
||||||
|
|
@ -19281,15 +19259,21 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete cacheKey if we have a webGlBackend
|
* Delete a single texture if in webgl mode
|
||||||
* delete reference to image elements
|
|
||||||
*/
|
*/
|
||||||
dispose: function() {
|
removeTexture: function(key) {
|
||||||
var backend = fabric.filterBackend;
|
var backend = fabric.filterBackend;
|
||||||
if (backend && backend.evictCachesForKey) {
|
if (backend && backend.evictCachesForKey) {
|
||||||
backend.evictCachesForKey(this.cacheKey);
|
backend.evictCachesForKey(key);
|
||||||
backend.evictCachesForKey(this.cacheKey + '_filtered');
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete textures, reference to elements and eventually JSDOM cleanup
|
||||||
|
*/
|
||||||
|
dispose: function() {
|
||||||
|
this.removeTexture(this.cacheKey);
|
||||||
|
this.removeTexture(this.cacheKey + '_filtered');
|
||||||
this._cacheContext = undefined;
|
this._cacheContext = undefined;
|
||||||
['_originalElement', '_element', '_filteredEl', '_cacheCanvas'].forEach((function(element) {
|
['_originalElement', '_element', '_filteredEl', '_cacheCanvas'].forEach((function(element) {
|
||||||
fabric.util.cleanUpJsdomNode(this[element]);
|
fabric.util.cleanUpJsdomNode(this[element]);
|
||||||
|
|
@ -19513,7 +19497,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
fabric.filterBackend = fabric.initFilterBackend();
|
fabric.filterBackend = fabric.initFilterBackend();
|
||||||
}
|
}
|
||||||
var canvasEl = fabric.util.createCanvasElement(),
|
var canvasEl = fabric.util.createCanvasElement(),
|
||||||
cacheKey = this._filteredEl ? this.cacheKey : (this.cacheKey + '_filtered'),
|
cacheKey = this._filteredEl ? (this.cacheKey + '_filtered') : this.cacheKey,
|
||||||
sourceWidth = elementToFilter.width, sourceHeight = elementToFilter.height;
|
sourceWidth = elementToFilter.width, sourceHeight = elementToFilter.height;
|
||||||
canvasEl.width = sourceWidth;
|
canvasEl.width = sourceWidth;
|
||||||
canvasEl.height = sourceHeight;
|
canvasEl.height = sourceHeight;
|
||||||
|
|
@ -19541,6 +19525,10 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
if (this.group) {
|
if (this.group) {
|
||||||
this.set('dirty', true);
|
this.set('dirty', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// needs to clear out or WEBGL will not resize correctly
|
||||||
|
this.removeTexture(this.cacheKey + '_filtered');
|
||||||
|
|
||||||
if (filters.length === 0) {
|
if (filters.length === 0) {
|
||||||
this._element = this._originalElement;
|
this._element = this._originalElement;
|
||||||
this._filteredEl = null;
|
this._filteredEl = null;
|
||||||
|
|
@ -19563,7 +19551,12 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// clear the existing element to get new filter data
|
// clear the existing element to get new filter data
|
||||||
this._element.getContext('2d').clearRect(0, 0, sourceWidth, sourceHeight);
|
// also dereference the eventual resized _element
|
||||||
|
this._element = this._filteredEl;
|
||||||
|
this._filteredEl.getContext('2d').clearRect(0, 0, sourceWidth, sourceHeight);
|
||||||
|
// we also need to resize again at next renderAll, so remove saved _lastScaleX/Y
|
||||||
|
this._lastScaleX = 1;
|
||||||
|
this._lastScaleY = 1;
|
||||||
}
|
}
|
||||||
if (!fabric.filterBackend) {
|
if (!fabric.filterBackend) {
|
||||||
fabric.filterBackend = fabric.initFilterBackend();
|
fabric.filterBackend = fabric.initFilterBackend();
|
||||||
|
|
@ -27288,13 +27281,15 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
|
||||||
*/
|
*/
|
||||||
mouseUpHandler: function(options) {
|
mouseUpHandler: function(options) {
|
||||||
this.__isMousedown = false;
|
this.__isMousedown = false;
|
||||||
if (!this.editable ||
|
if (!this.editable || this.group ||
|
||||||
(options.transform && options.transform.actionPerformed) ||
|
(options.transform && options.transform.actionPerformed) ||
|
||||||
(options.e.button && options.e.button !== 1)) {
|
(options.e.button && options.e.button !== 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.__lastSelected && !this.__corner) {
|
if (this.__lastSelected && !this.__corner) {
|
||||||
|
this.selected = false;
|
||||||
|
this.__lastSelected = false;
|
||||||
this.enterEditing(options.e);
|
this.enterEditing(options.e);
|
||||||
if (this.selectionStart === this.selectionEnd) {
|
if (this.selectionStart === this.selectionEnd) {
|
||||||
this.initDelayedCursor(true);
|
this.initDelayedCursor(true);
|
||||||
|
|
@ -27303,7 +27298,9 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
|
||||||
this.renderCursorOrSelection();
|
this.renderCursorOrSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.selected = true;
|
else {
|
||||||
|
this.selected = true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
2
dist/fabric.min.js
vendored
2
dist/fabric.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "fabric",
|
"name": "fabric",
|
||||||
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
|
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
|
||||||
"homepage": "http://fabricjs.com/",
|
"homepage": "http://fabricjs.com/",
|
||||||
"version": "2.3.4",
|
"version": "2.3.5",
|
||||||
"author": "Juriy Zaytsev <kangax@gmail.com>",
|
"author": "Juriy Zaytsev <kangax@gmail.com>",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue