This commit is contained in:
Andrea Bogazzi 2018-08-20 08:24:46 +02:00 committed by GitHub
parent e8a5ad446b
commit 7895099484
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 29 deletions

View file

@ -1,3 +1,8 @@
**Version 2.3.6**
- Fix: Make image.class aware of naturalWidth and naturalHeight. [#5178](https://github.com/fabricjs/fabric.js/pull/5178)
- Fix: Make 2 finger events works again [#5177](https://github.com/fabricjs/fabric.js/pull/5177)
- Fix: Make Groups respect origin and correct position ( fix spray/circle brushes ) [#5176](https://github.com/fabricjs/fabric.js/pull/5176)
**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)

View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: '2.3.5' };
var fabric = fabric || { version: '2.3.6' };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}

55
dist/fabric.js vendored
View file

@ -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: '2.3.5' };
var fabric = fabric || { version: '2.3.6' };
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
}
@ -6575,7 +6575,10 @@ fabric.ElementsParser.prototype.checkIfDone = function() {
/**
* Function that determines clipping of entire canvas area
* Being passed context as first argument. See clipping canvas area in {@link https://github.com/kangax/fabric.js/wiki/FAQ}
* Being passed context as first argument.
* If you are using code minification, ctx argument can be minified/manglied you should use
* as a workaround `var ctx = arguments[0];` in the function;
* See clipping canvas area in {@link https://github.com/kangax/fabric.js/wiki/FAQ}
* @deprecated since 2.0.0
* @type Function
* @default
@ -8746,7 +8749,7 @@ fabric.CircleBrush = fabric.util.createClass(fabric.BaseBrush, /** @lends fabric
circles.push(circle);
}
var group = new fabric.Group(circles, { originX: 'center', originY: 'center' });
var group = new fabric.Group(circles);
group.canvas = this.canvas;
this.canvas.add(group);
@ -8893,7 +8896,7 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric
rects = this._getOptimizedRects(rects);
}
var group = new fabric.Group(rects, { originX: 'center', originY: 'center' });
var group = new fabric.Group(rects);
this.shadow && group.setShadow(this.shadow);
this.canvas.add(group);
this.canvas.fire('path:created', { path: group });
@ -12702,7 +12705,9 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
includeDefaultValues: true,
/**
* Function that determines clipping of an object (context is passed as a first argument)
* Function that determines clipping of an object (context is passed as a first argument).
* If you are using code minification, ctx argument can be minified/manglied you should use
* as a workaround `var ctx = arguments[0];` in the function;
* Note that context origin is at the object's center point (not left/top corner)
* @deprecated since 2.0.0
* @type Function
@ -18457,6 +18462,16 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
if (!isAlreadyGrouped) {
var center = options && options.centerPoint;
// we want to set origins before calculating the bounding box.
// so that the topleft can be set with that in mind.
// if specific top and left are passed, are overwritten later
// with the callSuper('initialize', options)
if (options.originX !== undefined) {
this.originX = options.originX;
}
if (options.originY !== undefined) {
this.originY = options.originY;
}
// if coming from svg i do not want to calc bounds.
// i assume width and height are passed along options
center || this._calcBounds();
@ -18874,6 +18889,8 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
this.width = width;
this.height = height;
if (!onlyWidthHeight) {
// the bounding box always finds the topleft most corner.
// whatever is the group origin, we set up here the left/top position.
this.setPositionByOrigin({ x: left, y: top }, 'left', 'top');
}
},
@ -19231,7 +19248,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
* @return {HTMLImageElement} Image element
*/
getElement: function() {
return this._element;
return this._element || {};
},
/**
@ -19300,8 +19317,8 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
getOriginalSize: function() {
var element = this.getElement();
return {
width: element.width,
height: element.height
width: element.naturalWidth || element.width,
height: element.naturalHeight || element.height
};
},
@ -19606,10 +19623,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
* @private
*/
_resetWidthHeight: function() {
var element = this.getElement();
this.set('width', element.width);
this.set('height', element.height);
this.set(this.getOriginalSize());
},
/**
@ -19655,20 +19669,15 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* @private
* Set the width and the height of the image object, using the element or the
* options.
* @param {Object} [options] Object with width/height properties
*/
_setWidthHeight: function(options) {
this.width = options && ('width' in options)
? options.width
: (this.getElement()
? this.getElement().width || 0
: 0);
this.height = options && ('height' in options)
? options.height
: (this.getElement()
? this.getElement().height || 0
: 0);
options || (options = { });
var el = this.getElement();
this.width = options.width || el.naturalWidth || el.width || 0;
this.height = options.height || el.naturalHeight || el.height || 0;
},
/**

2
dist/fabric.min.js vendored

File diff suppressed because one or more lines are too long

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": "2.3.5",
"version": "2.3.6",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"contributors": [
{
@ -33,10 +33,10 @@
},
"repository": {
"type": "git",
"url": "https://github.com/kangax/fabric.js"
"url": "https://github.com/fabric/fabric.js"
},
"bugs": {
"url": "https://github.com/kangax/fabric.js/issues"
"url": "https://github.com/fabric/fabric.js/issues"
},
"license": "MIT",
"scripts": {
@ -53,7 +53,7 @@
"lint_tests": "eslint test/unit --config .eslintrc_tests",
"export_dist_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric.js && cp package.json ../fabricjs.com/lib/package.json && cp -r src HEADER.js lib ../fabricjs.com/build/files/",
"export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit && cp -r test/visual/* ../fabricjs.com/test/visual && cp -r test/fixtures/* ../fabricjs.com/test/fixtures",
"all": "npm run build && npm run test && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site",
"all": "npm run build && npm run test && npm run test:visual && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site",
"testem": "testem .",
"testem:visual": "testem --file testem-visual.json",
"testem:ci": "testem ci"