fabric 4.6.0 → 5.0.0-browser
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/HEADER.js +1 -1
- package/README.md +1 -6
- package/SECURITY.md +5 -0
- package/dist/fabric.js +652 -393
- package/dist/fabric.min.js +1 -1
- package/lib/event.js +7 -3
- package/package.json +87 -88
- package/src/brushes/base_brush.class.js +2 -2
- package/src/brushes/pattern_brush.class.js +7 -5
- package/src/brushes/pencil_brush.class.js +33 -4
- package/src/canvas.class.js +9 -17
- package/src/mixins/animation.mixin.js +16 -21
- package/src/mixins/canvas_events.mixin.js +27 -56
- package/src/mixins/eraser_brush.mixin.js +354 -420
- package/src/mixins/itext_behavior.mixin.js +7 -1
- package/src/mixins/object_geometry.mixin.js +3 -34
- package/src/mixins/object_straightening.mixin.js +4 -9
- package/src/parser.js +13 -9
- package/src/shapes/circle.class.js +20 -17
- package/src/shapes/group.class.js +13 -25
- package/src/shapes/image.class.js +3 -3
- package/src/shapes/object.class.js +45 -19
- package/src/shapes/path.class.js +13 -9
- package/src/shapes/polygon.class.js +9 -1
- package/src/shapes/polyline.class.js +33 -9
- package/src/shapes/text.class.js +38 -21
- package/src/static_canvas.class.js +15 -7
- package/src/util/animate.js +146 -22
- package/src/util/misc.js +193 -45
- package/src/util/path.js +2 -56
package/lib/event.js
CHANGED
|
@@ -1368,7 +1368,11 @@ root.gesture = function(conf) {
|
|
|
1368
1368
|
var dx = touch.move.x - self.x;
|
|
1369
1369
|
var dy = touch.move.y - self.y;
|
|
1370
1370
|
var distance = Math.sqrt(dx * dx + dy * dy);
|
|
1371
|
-
|
|
1371
|
+
// If touch start.distance from centroid is 0, scale should not be updated.
|
|
1372
|
+
// This prevents dividing by 0 in cases where start.distance is oddly 0.
|
|
1373
|
+
if (start.distance !== 0) {
|
|
1374
|
+
scale += distance / start.distance;
|
|
1375
|
+
}
|
|
1372
1376
|
// Calculate rotation.
|
|
1373
1377
|
var angle = Math.atan2(dx, dy) / RAD_DEG;
|
|
1374
1378
|
var rotate = (start.angle - angle + 360) % 360 - 180;
|
|
@@ -1765,8 +1769,8 @@ root.tap = function(conf) {
|
|
|
1765
1769
|
var identifier = touch.identifier || Infinity;
|
|
1766
1770
|
var pt = conf.tracker[identifier];
|
|
1767
1771
|
if (!pt) continue;
|
|
1768
|
-
var x = (touch.pageX - bbox.x1);
|
|
1769
|
-
var y = (touch.pageY - bbox.y1);
|
|
1772
|
+
var x = (touch.pageX - bbox.x1 - parseInt(window.scrollX));
|
|
1773
|
+
var y = (touch.pageY - bbox.y1 - parseInt(window.scrollY));
|
|
1770
1774
|
///
|
|
1771
1775
|
var dx = x - pt.start.x;
|
|
1772
1776
|
var dy = y - pt.start.y;
|
package/package.json
CHANGED
|
@@ -1,89 +1,88 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
2
|
+
"name": "fabric",
|
|
3
|
+
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
|
|
4
|
+
"homepage": "http://fabricjs.com/",
|
|
5
|
+
"version": "5.0.0-browser",
|
|
6
|
+
"author": "Juriy Zaytsev <kangax@gmail.com>",
|
|
7
|
+
"contributors": [
|
|
8
|
+
{
|
|
9
|
+
"name": "Andrea Bogazzi",
|
|
10
|
+
"email": "andreabogazzi79@gmail.com"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "Steve Eberhardt",
|
|
14
|
+
"email": "melchiar2@gmail.com"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"canvas",
|
|
19
|
+
"graphic",
|
|
20
|
+
"graphics",
|
|
21
|
+
"SVG",
|
|
22
|
+
"node-canvas",
|
|
23
|
+
"parser",
|
|
24
|
+
"HTML5",
|
|
25
|
+
"object model"
|
|
26
|
+
],
|
|
27
|
+
"browser": {
|
|
28
|
+
"canvas": false,
|
|
29
|
+
"fs": false,
|
|
30
|
+
"jsdom": false,
|
|
31
|
+
"jsdom/lib/jsdom/living/generated/utils": false,
|
|
32
|
+
"jsdom/lib/jsdom/utils": false,
|
|
33
|
+
"http": false,
|
|
34
|
+
"https": false,
|
|
35
|
+
"xmldom": false,
|
|
36
|
+
"url": false
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/fabricjs/fabric.js"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/fabricjs/fabric.js/issues"
|
|
44
|
+
},
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"scripts": {
|
|
47
|
+
"changelog": "auto-changelog -o change-output.md --unreleased-only",
|
|
48
|
+
"build": "node build.js modules=ALL requirejs exclude=gestures,accessors,erasing",
|
|
49
|
+
"build:fast": "node build.js modules=ALL requirejs fast exclude=gestures,accessors,erasing",
|
|
50
|
+
"build:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm run build_export",
|
|
51
|
+
"link:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm link",
|
|
52
|
+
"build_with_gestures": "node build.js modules=ALL exclude=accessors",
|
|
53
|
+
"build_export": "npm run build:fast && npm run export_dist_to_site",
|
|
54
|
+
"test:single": "qunit test/node_test_setup.js test/lib",
|
|
55
|
+
"test:coverage": "nyc --silent qunit test/node_test_setup.js test/lib test/unit",
|
|
56
|
+
"test:visual:coverage": "nyc --silent --no-clean qunit test/node_test_setup.js test/lib test/visual",
|
|
57
|
+
"coverage:report": "nyc report --reporter=lcov --reporter=text",
|
|
58
|
+
"test": "qunit test/node_test_setup.js test/lib test/unit",
|
|
59
|
+
"test:visual": "qunit test/node_test_setup.js test/lib test/visual",
|
|
60
|
+
"test:visual:single": "qunit test/node_test_setup.js test/lib",
|
|
61
|
+
"test:all": "npm run test && npm run test:visual",
|
|
62
|
+
"lint": "eslint --config .eslintrc.json src",
|
|
63
|
+
"lint_tests": "eslint test/unit --config .eslintrc_tests && eslint test/visual --config .eslintrc_tests",
|
|
64
|
+
"export_gesture_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric_with_gestures.js",
|
|
65
|
+
"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/",
|
|
66
|
+
"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 && cp -r test/lib/* ../fabricjs.com/test/lib",
|
|
67
|
+
"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",
|
|
68
|
+
"testem": "testem .",
|
|
69
|
+
"testem:ci": "testem ci"
|
|
70
|
+
},
|
|
71
|
+
"optionalDependencies": {},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"auto-changelog": "^2.3.0",
|
|
74
|
+
"chalk": "^2.4.1",
|
|
75
|
+
"eslint": "4.18.x",
|
|
76
|
+
"nyc": "^15.1.0",
|
|
77
|
+
"onchange": "^7.1.0",
|
|
78
|
+
"pixelmatch": "^4.0.2",
|
|
79
|
+
"qunit": "^2.13.0",
|
|
80
|
+
"testem": "^3.2.0",
|
|
81
|
+
"uglify-js": "3.3.x"
|
|
82
|
+
},
|
|
83
|
+
"engines": {
|
|
84
|
+
"node": ">=14.0.0"
|
|
85
|
+
},
|
|
86
|
+
"main": "./dist/fabric.js",
|
|
87
|
+
"dependencies": {}
|
|
88
|
+
}
|
|
@@ -68,9 +68,9 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype
|
|
|
68
68
|
/**
|
|
69
69
|
* Sets brush styles
|
|
70
70
|
* @private
|
|
71
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
71
72
|
*/
|
|
72
|
-
_setBrushStyles: function() {
|
|
73
|
-
var ctx = this.canvas.contextTop;
|
|
73
|
+
_setBrushStyles: function (ctx) {
|
|
74
74
|
ctx.strokeStyle = this.color;
|
|
75
75
|
ctx.lineWidth = this.width;
|
|
76
76
|
ctx.lineCap = this.strokeLineCap;
|
|
@@ -29,17 +29,19 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Creates "pattern" instance property
|
|
32
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
32
33
|
*/
|
|
33
|
-
getPattern: function() {
|
|
34
|
-
return
|
|
34
|
+
getPattern: function(ctx) {
|
|
35
|
+
return ctx.createPattern(this.source || this.getPatternSrc(), 'repeat');
|
|
35
36
|
},
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Sets brush styles
|
|
40
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
39
41
|
*/
|
|
40
|
-
_setBrushStyles: function() {
|
|
41
|
-
this.callSuper('_setBrushStyles');
|
|
42
|
-
|
|
42
|
+
_setBrushStyles: function(ctx) {
|
|
43
|
+
this.callSuper('_setBrushStyles', ctx);
|
|
44
|
+
ctx.strokeStyle = this.getPattern(ctx);
|
|
43
45
|
},
|
|
44
46
|
|
|
45
47
|
/**
|
|
@@ -13,6 +13,22 @@
|
|
|
13
13
|
*/
|
|
14
14
|
decimate: 0.4,
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Draws a straight line between last recorded point to current pointer
|
|
18
|
+
* Used for `shift` functionality
|
|
19
|
+
*
|
|
20
|
+
* @type boolean
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
drawStraightLine: false,
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The event modifier key that makes the brush draw a straight line.
|
|
27
|
+
* If `null` or 'none' or any other string that is not a modifier key the feature is disabled.
|
|
28
|
+
* @type {'altKey' | 'shiftKey' | 'ctrlKey' | 'none' | undefined | null}
|
|
29
|
+
*/
|
|
30
|
+
straightLineKey: 'shiftKey',
|
|
31
|
+
|
|
16
32
|
/**
|
|
17
33
|
* Constructor
|
|
18
34
|
* @param {fabric.Canvas} canvas
|
|
@@ -23,6 +39,10 @@
|
|
|
23
39
|
this._points = [];
|
|
24
40
|
},
|
|
25
41
|
|
|
42
|
+
needsFullRender: function () {
|
|
43
|
+
return this.callSuper('needsFullRender') || this._hasStraightLine;
|
|
44
|
+
},
|
|
45
|
+
|
|
26
46
|
/**
|
|
27
47
|
* Invoked inside on mouse down and mouse move
|
|
28
48
|
* @param {Object} pointer
|
|
@@ -41,6 +61,7 @@
|
|
|
41
61
|
if (!this.canvas._isMainEvent(options.e)) {
|
|
42
62
|
return;
|
|
43
63
|
}
|
|
64
|
+
this.drawStraightLine = options.e[this.straightLineKey];
|
|
44
65
|
this._prepareForDrawing(pointer);
|
|
45
66
|
// capture coordinates immediately
|
|
46
67
|
// this allows to draw dots (when movement never occurs)
|
|
@@ -56,6 +77,7 @@
|
|
|
56
77
|
if (!this.canvas._isMainEvent(options.e)) {
|
|
57
78
|
return;
|
|
58
79
|
}
|
|
80
|
+
this.drawStraightLine = options.e[this.straightLineKey];
|
|
59
81
|
if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {
|
|
60
82
|
return;
|
|
61
83
|
}
|
|
@@ -88,6 +110,7 @@
|
|
|
88
110
|
if (!this.canvas._isMainEvent(options.e)) {
|
|
89
111
|
return true;
|
|
90
112
|
}
|
|
113
|
+
this.drawStraightLine = false;
|
|
91
114
|
this.oldEnd = undefined;
|
|
92
115
|
this._finalizeAndAddPath();
|
|
93
116
|
return false;
|
|
@@ -114,6 +137,10 @@
|
|
|
114
137
|
if (this._points.length > 1 && point.eq(this._points[this._points.length - 1])) {
|
|
115
138
|
return false;
|
|
116
139
|
}
|
|
140
|
+
if (this.drawStraightLine && this._points.length > 1) {
|
|
141
|
+
this._hasStraightLine = true;
|
|
142
|
+
this._points.pop();
|
|
143
|
+
}
|
|
117
144
|
this._points.push(point);
|
|
118
145
|
return true;
|
|
119
146
|
},
|
|
@@ -124,8 +151,9 @@
|
|
|
124
151
|
*/
|
|
125
152
|
_reset: function() {
|
|
126
153
|
this._points = [];
|
|
127
|
-
this._setBrushStyles();
|
|
154
|
+
this._setBrushStyles(this.canvas.contextTop);
|
|
128
155
|
this._setShadow();
|
|
156
|
+
this._hasStraightLine = false;
|
|
129
157
|
},
|
|
130
158
|
|
|
131
159
|
/**
|
|
@@ -140,12 +168,13 @@
|
|
|
140
168
|
/**
|
|
141
169
|
* Draw a smooth path on the topCanvas using quadraticCurveTo
|
|
142
170
|
* @private
|
|
171
|
+
* @param {CanvasRenderingContext2D} [ctx]
|
|
143
172
|
*/
|
|
144
|
-
_render: function() {
|
|
145
|
-
var
|
|
173
|
+
_render: function(ctx) {
|
|
174
|
+
var i, len,
|
|
146
175
|
p1 = this._points[0],
|
|
147
176
|
p2 = this._points[1];
|
|
148
|
-
|
|
177
|
+
ctx = ctx || this.canvas.contextTop;
|
|
149
178
|
this._saveAndTransform(ctx);
|
|
150
179
|
ctx.beginPath();
|
|
151
180
|
//if we only have 2 points in the path and they are the same
|
package/src/canvas.class.js
CHANGED
|
@@ -37,15 +37,11 @@
|
|
|
37
37
|
* @fires dragover
|
|
38
38
|
* @fires dragenter
|
|
39
39
|
* @fires dragleave
|
|
40
|
+
* @fires drop:before before drop event. same native event. This is added to handle edge cases
|
|
40
41
|
* @fires drop
|
|
41
42
|
* @fires after:render at the end of the render process, receives the context in the callback
|
|
42
43
|
* @fires before:render at start the render process, receives the context in the callback
|
|
43
44
|
*
|
|
44
|
-
* the following events are deprecated:
|
|
45
|
-
* @fires object:rotated at the end of a rotation transform
|
|
46
|
-
* @fires object:scaled at the end of a scale transform
|
|
47
|
-
* @fires object:moved at the end of translation transform
|
|
48
|
-
* @fires object:skewed at the end of a skew transform
|
|
49
45
|
*/
|
|
50
46
|
fabric.Canvas = fabric.util.createClass(fabric.StaticCanvas, /** @lends fabric.Canvas.prototype */ {
|
|
51
47
|
|
|
@@ -230,13 +226,6 @@
|
|
|
230
226
|
*/
|
|
231
227
|
freeDrawingCursor: 'crosshair',
|
|
232
228
|
|
|
233
|
-
/**
|
|
234
|
-
* Cursor value used for rotation point
|
|
235
|
-
* @type String
|
|
236
|
-
* @default
|
|
237
|
-
*/
|
|
238
|
-
rotationCursor: 'crosshair',
|
|
239
|
-
|
|
240
229
|
/**
|
|
241
230
|
* Cursor value used for disabled elements ( corners with disabled action )
|
|
242
231
|
* @type String
|
|
@@ -342,6 +331,13 @@
|
|
|
342
331
|
*/
|
|
343
332
|
targets: [],
|
|
344
333
|
|
|
334
|
+
/**
|
|
335
|
+
* When the option is enabled, PointerEvent is used instead of MouseEvent.
|
|
336
|
+
* @type Boolean
|
|
337
|
+
* @default
|
|
338
|
+
*/
|
|
339
|
+
enablePointerEvents: false,
|
|
340
|
+
|
|
345
341
|
/**
|
|
346
342
|
* Keep track of the hovered target
|
|
347
343
|
* @type fabric.Object
|
|
@@ -417,6 +413,7 @@
|
|
|
417
413
|
}
|
|
418
414
|
if (this.hasLostContext) {
|
|
419
415
|
this.renderTopLayer(this.contextTop);
|
|
416
|
+
this.hasLostContext = false;
|
|
420
417
|
}
|
|
421
418
|
var canvasToDrawOn = this.contextContainer;
|
|
422
419
|
this.renderCanvas(canvasToDrawOn, this._chooseObjectsToRender());
|
|
@@ -1086,17 +1083,12 @@
|
|
|
1086
1083
|
e: e,
|
|
1087
1084
|
selected: added,
|
|
1088
1085
|
deselected: removed,
|
|
1089
|
-
// added for backward compatibility
|
|
1090
|
-
// deprecated
|
|
1091
|
-
updated: added[0] || removed[0],
|
|
1092
|
-
target: this._activeObject,
|
|
1093
1086
|
});
|
|
1094
1087
|
}
|
|
1095
1088
|
else if (objects.length > 0) {
|
|
1096
1089
|
this.fire('selection:created', {
|
|
1097
1090
|
e: e,
|
|
1098
1091
|
selected: added,
|
|
1099
|
-
target: this._activeObject,
|
|
1100
1092
|
});
|
|
1101
1093
|
}
|
|
1102
1094
|
else if (oldObjects.length > 0) {
|
|
@@ -13,8 +13,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
|
|
|
13
13
|
* @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties
|
|
14
14
|
* @param {Function} [callbacks.onComplete] Invoked on completion
|
|
15
15
|
* @param {Function} [callbacks.onChange] Invoked on every step of animation
|
|
16
|
-
* @return {fabric.
|
|
17
|
-
* @chainable
|
|
16
|
+
* @return {fabric.AnimationContext} context
|
|
18
17
|
*/
|
|
19
18
|
fxCenterObjectH: function (object, callbacks) {
|
|
20
19
|
callbacks = callbacks || { };
|
|
@@ -24,7 +23,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
|
|
|
24
23
|
onChange = callbacks.onChange || empty,
|
|
25
24
|
_this = this;
|
|
26
25
|
|
|
27
|
-
fabric.util.animate({
|
|
26
|
+
return fabric.util.animate({
|
|
27
|
+
target: this,
|
|
28
28
|
startValue: object.left,
|
|
29
29
|
endValue: this.getCenter().left,
|
|
30
30
|
duration: this.FX_DURATION,
|
|
@@ -38,8 +38,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
|
|
|
38
38
|
onComplete();
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
-
|
|
42
|
-
return this;
|
|
43
41
|
},
|
|
44
42
|
|
|
45
43
|
/**
|
|
@@ -48,8 +46,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
|
|
|
48
46
|
* @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties
|
|
49
47
|
* @param {Function} [callbacks.onComplete] Invoked on completion
|
|
50
48
|
* @param {Function} [callbacks.onChange] Invoked on every step of animation
|
|
51
|
-
* @return {fabric.
|
|
52
|
-
* @chainable
|
|
49
|
+
* @return {fabric.AnimationContext} context
|
|
53
50
|
*/
|
|
54
51
|
fxCenterObjectV: function (object, callbacks) {
|
|
55
52
|
callbacks = callbacks || { };
|
|
@@ -59,7 +56,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
|
|
|
59
56
|
onChange = callbacks.onChange || empty,
|
|
60
57
|
_this = this;
|
|
61
58
|
|
|
62
|
-
fabric.util.animate({
|
|
59
|
+
return fabric.util.animate({
|
|
60
|
+
target: this,
|
|
63
61
|
startValue: object.top,
|
|
64
62
|
endValue: this.getCenter().top,
|
|
65
63
|
duration: this.FX_DURATION,
|
|
@@ -73,8 +71,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
|
|
|
73
71
|
onComplete();
|
|
74
72
|
}
|
|
75
73
|
});
|
|
76
|
-
|
|
77
|
-
return this;
|
|
78
74
|
},
|
|
79
75
|
|
|
80
76
|
/**
|
|
@@ -83,8 +79,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
|
|
|
83
79
|
* @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties
|
|
84
80
|
* @param {Function} [callbacks.onComplete] Invoked on completion
|
|
85
81
|
* @param {Function} [callbacks.onChange] Invoked on every step of animation
|
|
86
|
-
* @return {fabric.
|
|
87
|
-
* @chainable
|
|
82
|
+
* @return {fabric.AnimationContext} context
|
|
88
83
|
*/
|
|
89
84
|
fxRemove: function (object, callbacks) {
|
|
90
85
|
callbacks = callbacks || { };
|
|
@@ -94,7 +89,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
|
|
|
94
89
|
onChange = callbacks.onChange || empty,
|
|
95
90
|
_this = this;
|
|
96
91
|
|
|
97
|
-
fabric.util.animate({
|
|
92
|
+
return fabric.util.animate({
|
|
93
|
+
target: this,
|
|
98
94
|
startValue: object.opacity,
|
|
99
95
|
endValue: 0,
|
|
100
96
|
duration: this.FX_DURATION,
|
|
@@ -108,8 +104,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
|
|
|
108
104
|
onComplete();
|
|
109
105
|
}
|
|
110
106
|
});
|
|
111
|
-
|
|
112
|
-
return this;
|
|
113
107
|
}
|
|
114
108
|
});
|
|
115
109
|
|
|
@@ -120,7 +114,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
|
|
120
114
|
* @param {Number|Object} value Value to animate property to (if string was given first) or options object
|
|
121
115
|
* @return {fabric.Object} thisArg
|
|
122
116
|
* @tutorial {@link http://fabricjs.com/fabric-intro-part-2#animation}
|
|
123
|
-
* @
|
|
117
|
+
* @return {fabric.AnimationContext | fabric.AnimationContext[]} animation context (or an array if passed multiple properties)
|
|
124
118
|
*
|
|
125
119
|
* As object — multiple properties
|
|
126
120
|
*
|
|
@@ -133,22 +127,22 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
|
|
133
127
|
* object.animate('left', { duration: ... });
|
|
134
128
|
*
|
|
135
129
|
*/
|
|
136
|
-
animate: function() {
|
|
130
|
+
animate: function () {
|
|
137
131
|
if (arguments[0] && typeof arguments[0] === 'object') {
|
|
138
|
-
var propsToAnimate = [], prop, skipCallbacks;
|
|
132
|
+
var propsToAnimate = [], prop, skipCallbacks, out = [];
|
|
139
133
|
for (prop in arguments[0]) {
|
|
140
134
|
propsToAnimate.push(prop);
|
|
141
135
|
}
|
|
142
136
|
for (var i = 0, len = propsToAnimate.length; i < len; i++) {
|
|
143
137
|
prop = propsToAnimate[i];
|
|
144
138
|
skipCallbacks = i !== len - 1;
|
|
145
|
-
this._animate(prop, arguments[0][prop], arguments[1], skipCallbacks);
|
|
139
|
+
out.push(this._animate(prop, arguments[0][prop], arguments[1], skipCallbacks));
|
|
146
140
|
}
|
|
141
|
+
return out;
|
|
147
142
|
}
|
|
148
143
|
else {
|
|
149
|
-
this._animate.apply(this, arguments);
|
|
144
|
+
return this._animate.apply(this, arguments);
|
|
150
145
|
}
|
|
151
|
-
return this;
|
|
152
146
|
},
|
|
153
147
|
|
|
154
148
|
/**
|
|
@@ -196,6 +190,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
|
|
|
196
190
|
}
|
|
197
191
|
|
|
198
192
|
var _options = {
|
|
193
|
+
target: this,
|
|
199
194
|
startValue: options.from,
|
|
200
195
|
endValue: to,
|
|
201
196
|
byValue: options.by,
|