|
|
@@ -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.15" };
|
|
|
+var fabric = fabric || { version: "1.7.16" };
|
|
|
if (typeof exports !== 'undefined') {
|
|
|
exports.fabric = fabric;
|
|
|
}
|
|
|
@@ -2736,6 +2736,10 @@ if (typeof console !== 'undefined') { |
|
|
|
|
|
(function() {
|
|
|
|
|
|
+ function noop() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Changes value from one to another within certain period of time, invoking callbacks as value is being changed.
|
|
|
* @memberOf fabric.util
|
|
|
@@ -2756,8 +2760,9 @@ if (typeof console !== 'undefined') { |
|
|
var start = timestamp || +new Date(),
|
|
|
duration = options.duration || 500,
|
|
|
finish = start + duration, time,
|
|
|
- onChange = options.onChange || function() { },
|
|
|
- abort = options.abort || function() { return false; },
|
|
|
+ onChange = options.onChange || noop,
|
|
|
+ abort = options.abort || noop,
|
|
|
+ onComplete = options.onComplete || noop,
|
|
|
easing = options.easing || function(t, b, c, d) {return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;},
|
|
|
startValue = 'startValue' in options ? options.startValue : 0,
|
|
|
endValue = 'endValue' in options ? options.endValue : 100,
|
|
|
@@ -2766,13 +2771,16 @@ if (typeof console !== 'undefined') { |
|
|
options.onStart && options.onStart();
|
|
|
|
|
|
(function tick(ticktime) {
|
|
|
- time = ticktime || +new Date();
|
|
|
- var currentTime = time > finish ? duration : (time - start);
|
|
|
if (abort()) {
|
|
|
- options.onComplete && options.onComplete();
|
|
|
+ onComplete(endValue, 1, 1);
|
|
|
return;
|
|
|
}
|
|
|
- onChange(easing(currentTime, startValue, byValue, duration));
|
|
|
+ time = ticktime || +new Date();
|
|
|
+ var currentTime = time > finish ? duration : (time - start),
|
|
|
+ timePerc = currentTime / duration,
|
|
|
+ current = easing(currentTime, startValue, byValue, duration),
|
|
|
+ valuePerc = Math.abs((current - startValue) / byValue);
|
|
|
+ onChange(current, valuePerc, timePerc);
|
|
|
if (time > finish) {
|
|
|
options.onComplete && options.onComplete();
|
|
|
return;
|
|
|
@@ -10253,10 +10261,10 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab |
|
|
* @returns the original values of instance which were changed
|
|
|
*/
|
|
|
_realizeGroupTransformOnObject: function(instance) {
|
|
|
- var layoutProps = ['angle', 'flipX', 'flipY', 'height', 'left', 'scaleX', 'scaleY', 'top', 'width'];
|
|
|
if (instance.group && instance.group === this.getActiveGroup()) {
|
|
|
//Copy all the positionally relevant properties across now
|
|
|
- var originalValues = {};
|
|
|
+ var originalValues = {},
|
|
|
+ layoutProps = ['angle', 'flipX', 'flipY', 'left', 'scaleX', 'scaleY', 'skewX', 'skewY', 'top'];
|
|
|
layoutProps.forEach(function(prop) {
|
|
|
originalValues[prop] = instance[prop];
|
|
|
});
|
|
|
@@ -10663,7 +10671,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab |
|
|
isClick = (!groupSelector || (groupSelector.left === 0 && groupSelector.top === 0));
|
|
|
|
|
|
if (transform) {
|
|
|
- this._finalizeCurrentTransform();
|
|
|
+ this._finalizeCurrentTransform(e);
|
|
|
searchTarget = !transform.actionPerformed;
|
|
|
}
|
|
|
|
|
|
@@ -10718,8 +10726,9 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab |
|
|
|
|
|
/**
|
|
|
* @private
|
|
|
+ * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event
|
|
|
*/
|
|
|
- _finalizeCurrentTransform: function() {
|
|
|
+ _finalizeCurrentTransform: function(e) {
|
|
|
|
|
|
var transform = this._currentTransform,
|
|
|
target = transform.target;
|
|
|
@@ -10732,8 +10741,8 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab |
|
|
this._restoreOriginXY(target);
|
|
|
|
|
|
if (transform.actionPerformed || (this.stateful && target.hasStateChanged())) {
|
|
|
- this.fire('object:modified', { target: target });
|
|
|
- target.fire('modified');
|
|
|
+ this.fire('object:modified', { target: target, e: e });
|
|
|
+ target.fire('modified', { e: e });
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -14394,23 +14403,37 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati |
|
|
calcTransformMatrix: function(skipGroup) {
|
|
|
var center = this.getCenterPoint(),
|
|
|
translateMatrix = [1, 0, 0, 1, center.x, center.y],
|
|
|
- rotateMatrix = this._calcRotateMatrix(),
|
|
|
+ rotateMatrix,
|
|
|
dimensionMatrix = this._calcDimensionsTransformMatrix(this.skewX, this.skewY, true),
|
|
|
- matrix = this.group && !skipGroup ? this.group.calcTransformMatrix() : fabric.iMatrix.concat();
|
|
|
- matrix = multiplyMatrices(matrix, translateMatrix);
|
|
|
- matrix = multiplyMatrices(matrix, rotateMatrix);
|
|
|
+ matrix;
|
|
|
+ if (this.group && !skipGroup) {
|
|
|
+ matrix = multiplyMatrices(this.group.calcTransformMatrix(), translateMatrix);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ matrix = translateMatrix;
|
|
|
+ }
|
|
|
+ if (this.angle) {
|
|
|
+ rotateMatrix = this._calcRotateMatrix();
|
|
|
+ matrix = multiplyMatrices(matrix, rotateMatrix);
|
|
|
+ }
|
|
|
matrix = multiplyMatrices(matrix, dimensionMatrix);
|
|
|
return matrix;
|
|
|
},
|
|
|
|
|
|
_calcDimensionsTransformMatrix: function(skewX, skewY, flipping) {
|
|
|
- var skewMatrixX = [1, 0, Math.tan(degreesToRadians(skewX)), 1],
|
|
|
- skewMatrixY = [1, Math.tan(degreesToRadians(skewY)), 0, 1],
|
|
|
+ var skewMatrix,
|
|
|
scaleX = this.scaleX * (flipping && this.flipX ? -1 : 1),
|
|
|
scaleY = this.scaleY * (flipping && this.flipY ? -1 : 1),
|
|
|
- scaleMatrix = [scaleX, 0, 0, scaleY],
|
|
|
- m = multiplyMatrices(scaleMatrix, skewMatrixX, true);
|
|
|
- return multiplyMatrices(m, skewMatrixY, true);
|
|
|
+ scaleMatrix = [scaleX, 0, 0, scaleY, 0, 0];
|
|
|
+ if (skewX) {
|
|
|
+ skewMatrix = [1, 0, Math.tan(degreesToRadians(skewX)), 1];
|
|
|
+ scaleMatrix = multiplyMatrices(scaleMatrix, skewMatrix, true);
|
|
|
+ }
|
|
|
+ if (skewY) {
|
|
|
+ skewMatrix = [1, Math.tan(degreesToRadians(skewY)), 0, 1];
|
|
|
+ scaleMatrix = multiplyMatrices(scaleMatrix, skewMatrix, true);
|
|
|
+ }
|
|
|
+ return scaleMatrix;
|
|
|
},
|
|
|
|
|
|
/*
|
|
|
@@ -15414,7 +15437,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot |
|
|
abort: options.abort && function() {
|
|
|
return options.abort.call(_this);
|
|
|
},
|
|
|
- onChange: function(value) {
|
|
|
+ onChange: function(value, valueProgress, timeProgress) {
|
|
|
if (propPair) {
|
|
|
_this[propPair[0]][propPair[1]] = value;
|
|
|
}
|
|
|
@@ -15424,15 +15447,15 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot |
|
|
if (skipCallbacks) {
|
|
|
return;
|
|
|
}
|
|
|
- options.onChange && options.onChange();
|
|
|
+ options.onChange && options.onChange(value, valueProgress, timeProgress);
|
|
|
},
|
|
|
- onComplete: function() {
|
|
|
+ onComplete: function(value, valueProgress, timeProgress) {
|
|
|
if (skipCallbacks) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
_this.setCoords();
|
|
|
- options.onComplete && options.onComplete();
|
|
|
+ options.onComplete && options.onComplete(value, valueProgress, timeProgress);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
0 comments on commit
3d022bc