@rive-app/canvas-single 1.0.71 → 1.0.72
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/package.json +1 -1
- package/rive.d.ts +3 -2
- package/rive.js +121 -82
- package/rive.js.map +1 -1
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -46,11 +46,11 @@ export declare class Layout {
|
|
|
46
46
|
readonly maxX: number;
|
|
47
47
|
readonly maxY: number;
|
|
48
48
|
constructor(params?: LayoutParameters);
|
|
49
|
-
static new({ fit, alignment, minX, minY, maxX, maxY }: LayoutParameters): Layout;
|
|
49
|
+
static new({ fit, alignment, minX, minY, maxX, maxY, }: LayoutParameters): Layout;
|
|
50
50
|
/**
|
|
51
51
|
* Makes a copy of the layout, replacing any specified parameters
|
|
52
52
|
*/
|
|
53
|
-
copyWith({ fit, alignment, minX, minY, maxX, maxY }: LayoutParameters): Layout;
|
|
53
|
+
copyWith({ fit, alignment, minX, minY, maxX, maxY, }: LayoutParameters): Layout;
|
|
54
54
|
runtimeFit(rive: rc.RiveCanvas): rc.Fit;
|
|
55
55
|
runtimeAlignment(rive: rc.RiveCanvas): rc.Alignment;
|
|
56
56
|
}
|
|
@@ -256,6 +256,7 @@ export declare class Rive {
|
|
|
256
256
|
private readyForPlaying;
|
|
257
257
|
private runtime;
|
|
258
258
|
private artboard;
|
|
259
|
+
private eventCleanup;
|
|
259
260
|
private file;
|
|
260
261
|
private eventManager;
|
|
261
262
|
private taskQueue;
|
package/rive.js
CHANGED
|
@@ -141,7 +141,7 @@ k.run=Fc;if(k.preInit)for("function"==typeof k.preInit&&(k.preInit=[k.preInit]);
|
|
|
141
141
|
/* 2 */
|
|
142
142
|
/***/ ((module) => {
|
|
143
143
|
|
|
144
|
-
module.exports = JSON.parse('{"name":"@rive-app/canvas-single","version":"1.0.
|
|
144
|
+
module.exports = JSON.parse('{"name":"@rive-app/canvas-single","version":"1.0.72","description":"Rive\'s high-level canvas based web api all in one js file.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
145
145
|
|
|
146
146
|
/***/ }),
|
|
147
147
|
/* 3 */
|
|
@@ -177,56 +177,69 @@ const registerTouchInteractions = ({
|
|
|
177
177
|
alignment,
|
|
178
178
|
}) => {
|
|
179
179
|
if (!canvas || !stateMachines.length || !renderer || !rive || !artboard) {
|
|
180
|
-
return;
|
|
180
|
+
return null;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
const mouseCallback = (event) => {
|
|
184
|
+
const boundingRect = event.currentTarget.getBoundingClientRect();
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
const canvasX = event.clientX - boundingRect.left;
|
|
187
|
+
const canvasY = event.clientY - boundingRect.top;
|
|
188
|
+
const forwardMatrix = rive.computeAlignment(
|
|
189
|
+
fit,
|
|
190
|
+
alignment,
|
|
191
|
+
{
|
|
189
192
|
minX: 0,
|
|
190
193
|
minY: 0,
|
|
191
194
|
maxX: boundingRect.width,
|
|
192
195
|
maxY: boundingRect.height,
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
},
|
|
197
|
+
artboard.bounds
|
|
198
|
+
);
|
|
199
|
+
let invertedMatrix = new rive.Mat2D();
|
|
200
|
+
forwardMatrix.invert(invertedMatrix);
|
|
201
|
+
const canvasCoordinatesVector = new rive.Vec2D(canvasX, canvasY);
|
|
202
|
+
const transformedVector = rive.mapXY(
|
|
203
|
+
invertedMatrix,
|
|
204
|
+
canvasCoordinatesVector
|
|
205
|
+
);
|
|
206
|
+
const transformedX = transformedVector.x();
|
|
207
|
+
const transformedY = transformedVector.y();
|
|
200
208
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
break;
|
|
209
|
+
switch (event.type) {
|
|
210
|
+
// Pointer moving/hovering on the canvas
|
|
211
|
+
case 'mousemove': {
|
|
212
|
+
for (const stateMachine of stateMachines) {
|
|
213
|
+
stateMachine.pointerMove(transformedX, transformedY);
|
|
208
214
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
// Pointer click initiated but not released yet on the canvas
|
|
218
|
+
case 'mousedown': {
|
|
219
|
+
for (const stateMachine of stateMachines) {
|
|
220
|
+
stateMachine.pointerDown(transformedX, transformedY);
|
|
215
221
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
// Pointer click released on the canvas
|
|
225
|
+
case 'mouseup': {
|
|
226
|
+
for (const stateMachine of stateMachines) {
|
|
227
|
+
stateMachine.pointerUp(transformedX, transformedY);
|
|
222
228
|
}
|
|
223
|
-
|
|
229
|
+
break;
|
|
224
230
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
default:
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const callback = mouseCallback.bind(undefined);
|
|
235
|
+
canvas.addEventListener('mousemove', callback);
|
|
236
|
+
canvas.addEventListener('mousedown', callback);
|
|
237
|
+
canvas.addEventListener('mouseup', callback);
|
|
238
|
+
return () => {
|
|
239
|
+
canvas.removeEventListener('mousemove', callback);
|
|
240
|
+
canvas.removeEventListener('mousedown', callback);
|
|
241
|
+
canvas.removeEventListener('mouseup', callback);
|
|
242
|
+
};
|
|
230
243
|
};
|
|
231
244
|
|
|
232
245
|
|
|
@@ -406,7 +419,7 @@ var Layout = /** @class */ (function () {
|
|
|
406
419
|
minX: minX !== null && minX !== void 0 ? minX : this.minX,
|
|
407
420
|
minY: minY !== null && minY !== void 0 ? minY : this.minY,
|
|
408
421
|
maxX: maxX !== null && maxX !== void 0 ? maxX : this.maxX,
|
|
409
|
-
maxY: maxY !== null && maxY !== void 0 ? maxY : this.maxY
|
|
422
|
+
maxY: maxY !== null && maxY !== void 0 ? maxY : this.maxY,
|
|
410
423
|
});
|
|
411
424
|
};
|
|
412
425
|
// Returns fit for the Wasm runtime format
|
|
@@ -470,7 +483,7 @@ var RuntimeLoader = /** @class */ (function () {
|
|
|
470
483
|
RuntimeLoader.loadRuntime = function () {
|
|
471
484
|
_rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__.default({
|
|
472
485
|
// Loads Wasm bundle
|
|
473
|
-
locateFile: function (_) { return RuntimeLoader.wasmURL; }
|
|
486
|
+
locateFile: function (_) { return RuntimeLoader.wasmURL; },
|
|
474
487
|
}).then(function (rive) {
|
|
475
488
|
var _a;
|
|
476
489
|
RuntimeLoader.runtime = rive;
|
|
@@ -771,8 +784,8 @@ var Animator = /** @class */ (function () {
|
|
|
771
784
|
animatables = mapToStringArray(animatables);
|
|
772
785
|
// If animatables is empty, play or pause everything
|
|
773
786
|
if (animatables.length === 0) {
|
|
774
|
-
this.animations.forEach(function (a) { return a.playing = playing; });
|
|
775
|
-
this.stateMachines.forEach(function (m) { return m.playing = playing; });
|
|
787
|
+
this.animations.forEach(function (a) { return (a.playing = playing); });
|
|
788
|
+
this.stateMachines.forEach(function (m) { return (m.playing = playing); });
|
|
776
789
|
}
|
|
777
790
|
else {
|
|
778
791
|
// Play/pause already instanced items, or create new instances
|
|
@@ -838,11 +851,11 @@ var Animator = /** @class */ (function () {
|
|
|
838
851
|
return this.add(animatables, true);
|
|
839
852
|
};
|
|
840
853
|
/**
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
854
|
+
* Pauses named animations and state machines, or everything if nothing is
|
|
855
|
+
* specified
|
|
856
|
+
* @param animatables names of the animations and state machines to pause
|
|
857
|
+
* @returns a list of names of the animations and state machines paused
|
|
858
|
+
*/
|
|
846
859
|
Animator.prototype.pause = function (animatables) {
|
|
847
860
|
return this.add(animatables, false);
|
|
848
861
|
};
|
|
@@ -853,8 +866,10 @@ var Animator = /** @class */ (function () {
|
|
|
853
866
|
* @returns a list of names of the animations that were scrubbed
|
|
854
867
|
*/
|
|
855
868
|
Animator.prototype.scrub = function (animatables, value) {
|
|
856
|
-
var forScrubbing = this.animations.filter(function (a) {
|
|
857
|
-
|
|
869
|
+
var forScrubbing = this.animations.filter(function (a) {
|
|
870
|
+
return animatables.includes(a.name);
|
|
871
|
+
});
|
|
872
|
+
forScrubbing.forEach(function (a) { return (a.scrubTo = value); });
|
|
858
873
|
return forScrubbing.map(function (a) { return a.name; });
|
|
859
874
|
};
|
|
860
875
|
Object.defineProperty(Animator.prototype, "playing", {
|
|
@@ -863,7 +878,10 @@ var Animator = /** @class */ (function () {
|
|
|
863
878
|
* playing
|
|
864
879
|
*/
|
|
865
880
|
get: function () {
|
|
866
|
-
return this.animations
|
|
881
|
+
return this.animations
|
|
882
|
+
.filter(function (a) { return a.playing; })
|
|
883
|
+
.map(function (a) { return a.name; })
|
|
884
|
+
.concat(this.stateMachines.filter(function (m) { return m.playing; }).map(function (m) { return m.name; }));
|
|
867
885
|
},
|
|
868
886
|
enumerable: false,
|
|
869
887
|
configurable: true
|
|
@@ -874,7 +892,10 @@ var Animator = /** @class */ (function () {
|
|
|
874
892
|
* paused
|
|
875
893
|
*/
|
|
876
894
|
get: function () {
|
|
877
|
-
return this.animations
|
|
895
|
+
return this.animations
|
|
896
|
+
.filter(function (a) { return !a.playing; })
|
|
897
|
+
.map(function (a) { return a.name; })
|
|
898
|
+
.concat(this.stateMachines.filter(function (m) { return !m.playing; }).map(function (m) { return m.name; }));
|
|
878
899
|
},
|
|
879
900
|
enumerable: false,
|
|
880
901
|
configurable: true
|
|
@@ -891,7 +912,9 @@ var Animator = /** @class */ (function () {
|
|
|
891
912
|
var removedNames = [];
|
|
892
913
|
// Stop everything
|
|
893
914
|
if (animatables.length === 0) {
|
|
894
|
-
removedNames = this.animations
|
|
915
|
+
removedNames = this.animations
|
|
916
|
+
.map(function (a) { return a.name; })
|
|
917
|
+
.concat(this.stateMachines.map(function (m) { return m.name; }));
|
|
895
918
|
// Clean up before emptying the arrays
|
|
896
919
|
this.animations.forEach(function (a) { return a.cleanup(); });
|
|
897
920
|
this.stateMachines.forEach(function (m) { return m.cleanup(); });
|
|
@@ -901,17 +924,23 @@ var Animator = /** @class */ (function () {
|
|
|
901
924
|
}
|
|
902
925
|
else {
|
|
903
926
|
// Remove only the named animations/state machines
|
|
904
|
-
var animationsToRemove = this.animations.filter(function (a) {
|
|
927
|
+
var animationsToRemove = this.animations.filter(function (a) {
|
|
928
|
+
return animatables.includes(a.name);
|
|
929
|
+
});
|
|
905
930
|
animationsToRemove.forEach(function (a) {
|
|
906
931
|
a.cleanup();
|
|
907
932
|
_this.animations.splice(_this.animations.indexOf(a), 1);
|
|
908
933
|
});
|
|
909
|
-
var machinesToRemove = this.stateMachines.filter(function (m) {
|
|
934
|
+
var machinesToRemove = this.stateMachines.filter(function (m) {
|
|
935
|
+
return animatables.includes(m.name);
|
|
936
|
+
});
|
|
910
937
|
machinesToRemove.forEach(function (m) {
|
|
911
938
|
m.cleanup();
|
|
912
939
|
_this.stateMachines.splice(_this.stateMachines.indexOf(m), 1);
|
|
913
940
|
});
|
|
914
|
-
removedNames = animationsToRemove
|
|
941
|
+
removedNames = animationsToRemove
|
|
942
|
+
.map(function (a) { return a.name; })
|
|
943
|
+
.concat(machinesToRemove.map(function (m) { return m.name; }));
|
|
915
944
|
}
|
|
916
945
|
this.eventManager.fire({
|
|
917
946
|
type: EventType.Stop,
|
|
@@ -925,8 +954,8 @@ var Animator = /** @class */ (function () {
|
|
|
925
954
|
* Returns true if at least one animation is active
|
|
926
955
|
*/
|
|
927
956
|
get: function () {
|
|
928
|
-
return this.animations.reduce(function (acc, curr) { return acc || curr.playing; }, false)
|
|
929
|
-
|
|
957
|
+
return (this.animations.reduce(function (acc, curr) { return acc || curr.playing; }, false) ||
|
|
958
|
+
this.stateMachines.reduce(function (acc, curr) { return acc || curr.playing; }, false));
|
|
930
959
|
},
|
|
931
960
|
enumerable: false,
|
|
932
961
|
configurable: true
|
|
@@ -936,8 +965,8 @@ var Animator = /** @class */ (function () {
|
|
|
936
965
|
* Returns true if all animations are paused and there's at least one animation
|
|
937
966
|
*/
|
|
938
967
|
get: function () {
|
|
939
|
-
return !this.isPlaying &&
|
|
940
|
-
(this.animations.length > 0 || this.stateMachines.length > 0);
|
|
968
|
+
return (!this.isPlaying &&
|
|
969
|
+
(this.animations.length > 0 || this.stateMachines.length > 0));
|
|
941
970
|
},
|
|
942
971
|
enumerable: false,
|
|
943
972
|
configurable: true
|
|
@@ -962,11 +991,11 @@ var Animator = /** @class */ (function () {
|
|
|
962
991
|
if (this.animations.length === 0 && this.stateMachines.length === 0) {
|
|
963
992
|
if (this.artboard.animationCount() > 0) {
|
|
964
993
|
// Add the first animation
|
|
965
|
-
this.add([instancedName = this.artboard.animationByIndex(0).name], playing, fireEvent);
|
|
994
|
+
this.add([(instancedName = this.artboard.animationByIndex(0).name)], playing, fireEvent);
|
|
966
995
|
}
|
|
967
996
|
else if (this.artboard.stateMachineCount() > 0) {
|
|
968
997
|
// Add the first state machine
|
|
969
|
-
this.add([instancedName = this.artboard.stateMachineByIndex(0).name], playing, fireEvent);
|
|
998
|
+
this.add([(instancedName = this.artboard.stateMachineByIndex(0).name)], playing, fireEvent);
|
|
970
999
|
}
|
|
971
1000
|
}
|
|
972
1001
|
return instancedName;
|
|
@@ -986,7 +1015,7 @@ var Animator = /** @class */ (function () {
|
|
|
986
1015
|
else if (animation.loopValue === 1 && animation.loopCount) {
|
|
987
1016
|
this.eventManager.fire({
|
|
988
1017
|
type: EventType.Loop,
|
|
989
|
-
data: { animation: animation.name, type: LoopType.Loop }
|
|
1018
|
+
data: { animation: animation.name, type: LoopType.Loop },
|
|
990
1019
|
});
|
|
991
1020
|
animation.loopCount = 0;
|
|
992
1021
|
}
|
|
@@ -996,7 +1025,7 @@ var Animator = /** @class */ (function () {
|
|
|
996
1025
|
else if (animation.loopValue === 2 && animation.loopCount > 1) {
|
|
997
1026
|
this.eventManager.fire({
|
|
998
1027
|
type: EventType.Loop,
|
|
999
|
-
data: { animation: animation.name, type: LoopType.PingPong }
|
|
1028
|
+
data: { animation: animation.name, type: LoopType.PingPong },
|
|
1000
1029
|
});
|
|
1001
1030
|
animation.loopCount = 0;
|
|
1002
1031
|
}
|
|
@@ -1044,7 +1073,7 @@ var LoopType;
|
|
|
1044
1073
|
(function (LoopType) {
|
|
1045
1074
|
LoopType["OneShot"] = "oneshot";
|
|
1046
1075
|
LoopType["Loop"] = "loop";
|
|
1047
|
-
LoopType["PingPong"] = "pingpong";
|
|
1076
|
+
LoopType["PingPong"] = "pingpong";
|
|
1048
1077
|
})(LoopType || (LoopType = {}));
|
|
1049
1078
|
// Manages Rive events and listeners
|
|
1050
1079
|
var EventManager = /** @class */ (function () {
|
|
@@ -1148,6 +1177,8 @@ var Rive = /** @class */ (function () {
|
|
|
1148
1177
|
this.readyForPlaying = false;
|
|
1149
1178
|
// Runtime artboard
|
|
1150
1179
|
this.artboard = null;
|
|
1180
|
+
// place to clear up event listeners
|
|
1181
|
+
this.eventCleanup = null;
|
|
1151
1182
|
// Durations to generate a frame for the last second. Used for performance profiling.
|
|
1152
1183
|
this.durations = [];
|
|
1153
1184
|
this.frameTimes = [];
|
|
@@ -1228,7 +1259,8 @@ var Rive = /** @class */ (function () {
|
|
|
1228
1259
|
this.loaded = false;
|
|
1229
1260
|
this.readyForPlaying = false;
|
|
1230
1261
|
// Ensure the runtime is loaded
|
|
1231
|
-
RuntimeLoader.awaitInstance()
|
|
1262
|
+
RuntimeLoader.awaitInstance()
|
|
1263
|
+
.then(function (runtime) {
|
|
1232
1264
|
_this.runtime = runtime;
|
|
1233
1265
|
// Get the canvas where you want to render the animation and create a renderer
|
|
1234
1266
|
_this.renderer = _this.runtime.makeRenderer(_this.canvas, useOffscreenRenderer);
|
|
@@ -1242,7 +1274,7 @@ var Rive = /** @class */ (function () {
|
|
|
1242
1274
|
var activeStateMachineInstances = (_this.animator.stateMachines || [])
|
|
1243
1275
|
.filter(function (sm) { return sm.playing; })
|
|
1244
1276
|
.map(function (sm) { return sm.instance; });
|
|
1245
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
|
|
1277
|
+
_this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
|
|
1246
1278
|
canvas: _this.canvas,
|
|
1247
1279
|
artboard: _this.artboard,
|
|
1248
1280
|
stateMachines: activeStateMachineInstances,
|
|
@@ -1255,7 +1287,8 @@ var Rive = /** @class */ (function () {
|
|
|
1255
1287
|
.catch(function (e) {
|
|
1256
1288
|
console.error(e);
|
|
1257
1289
|
});
|
|
1258
|
-
})
|
|
1290
|
+
})
|
|
1291
|
+
.catch(function (e) {
|
|
1259
1292
|
console.error(e);
|
|
1260
1293
|
});
|
|
1261
1294
|
};
|
|
@@ -1287,7 +1320,7 @@ var Rive = /** @class */ (function () {
|
|
|
1287
1320
|
this.loaded = true;
|
|
1288
1321
|
this.eventManager.fire({
|
|
1289
1322
|
type: EventType.Load,
|
|
1290
|
-
data: (_a = this.src) !== null && _a !== void 0 ? _a : 'buffer'
|
|
1323
|
+
data: (_a = this.src) !== null && _a !== void 0 ? _a : 'buffer',
|
|
1291
1324
|
});
|
|
1292
1325
|
// Flag ready for playback commands and clear the task queue; this order
|
|
1293
1326
|
// is important or it may infinitely recurse
|
|
@@ -1310,9 +1343,9 @@ var Rive = /** @class */ (function () {
|
|
|
1310
1343
|
// Initialize for playback
|
|
1311
1344
|
Rive.prototype.initArtboard = function (artboardName, animationNames, stateMachineNames, autoplay) {
|
|
1312
1345
|
// Fetch the artboard
|
|
1313
|
-
var rootArtboard = artboardName
|
|
1314
|
-
this.file.artboardByName(artboardName)
|
|
1315
|
-
this.file.defaultArtboard();
|
|
1346
|
+
var rootArtboard = artboardName
|
|
1347
|
+
? this.file.artboardByName(artboardName)
|
|
1348
|
+
: this.file.defaultArtboard();
|
|
1316
1349
|
// Check we have a working artboard
|
|
1317
1350
|
if (!rootArtboard) {
|
|
1318
1351
|
var msg = 'Invalid artboard name or no default artboard';
|
|
@@ -1347,7 +1380,7 @@ var Rive = /** @class */ (function () {
|
|
|
1347
1380
|
event: {
|
|
1348
1381
|
type: autoplay ? EventType.Play : EventType.Pause,
|
|
1349
1382
|
data: instanceNames,
|
|
1350
|
-
}
|
|
1383
|
+
},
|
|
1351
1384
|
});
|
|
1352
1385
|
};
|
|
1353
1386
|
// Draws the current artboard frame
|
|
@@ -1367,7 +1400,7 @@ var Rive = /** @class */ (function () {
|
|
|
1367
1400
|
this.lastRenderTime = time;
|
|
1368
1401
|
}
|
|
1369
1402
|
// Handle the onSecond callback
|
|
1370
|
-
this.renderSecondTimer +=
|
|
1403
|
+
this.renderSecondTimer += time - this.lastRenderTime;
|
|
1371
1404
|
if (this.renderSecondTimer > 5000) {
|
|
1372
1405
|
this.renderSecondTimer = 0;
|
|
1373
1406
|
onSecond === null || onSecond === void 0 ? void 0 : onSecond();
|
|
@@ -1378,10 +1411,11 @@ var Rive = /** @class */ (function () {
|
|
|
1378
1411
|
// - Advance non-paused animations by the elapsed number of seconds
|
|
1379
1412
|
// - Advance any animations that require scrubbing
|
|
1380
1413
|
// - Advance to the first frame even when autoplay is false
|
|
1381
|
-
var activeAnimations = this.animator.animations
|
|
1414
|
+
var activeAnimations = this.animator.animations
|
|
1415
|
+
.filter(function (a) { return a.playing || a.needsScrub; })
|
|
1382
1416
|
// The scrubbed animations must be applied first to prevent weird artifacts
|
|
1383
1417
|
// if the playing animations conflict with the scrubbed animating attribuates.
|
|
1384
|
-
.sort(function (first, second) { return first.needsScrub ? -1 : 1; });
|
|
1418
|
+
.sort(function (first, second) { return (first.needsScrub ? -1 : 1); });
|
|
1385
1419
|
for (var _i = 0, activeAnimations_1 = activeAnimations; _i < activeAnimations_1.length; _i++) {
|
|
1386
1420
|
var animation = activeAnimations_1[_i];
|
|
1387
1421
|
animation.advance(elapsedTime);
|
|
@@ -1451,7 +1485,7 @@ var Rive = /** @class */ (function () {
|
|
|
1451
1485
|
minX: _layout.minX,
|
|
1452
1486
|
minY: _layout.minY,
|
|
1453
1487
|
maxX: _layout.maxX,
|
|
1454
|
-
maxY: _layout.maxY
|
|
1488
|
+
maxY: _layout.maxY,
|
|
1455
1489
|
}, artboard.bounds);
|
|
1456
1490
|
};
|
|
1457
1491
|
Object.defineProperty(Rive.prototype, "fps", {
|
|
@@ -1479,6 +1513,9 @@ var Rive = /** @class */ (function () {
|
|
|
1479
1513
|
* might happen.
|
|
1480
1514
|
*/
|
|
1481
1515
|
Rive.prototype.cleanup = function () {
|
|
1516
|
+
if (this.eventCleanup !== null) {
|
|
1517
|
+
this.eventCleanup();
|
|
1518
|
+
}
|
|
1482
1519
|
this.artboard.delete();
|
|
1483
1520
|
// TODO: delete animation and state machine instances
|
|
1484
1521
|
};
|
|
@@ -1557,6 +1594,7 @@ var Rive = /** @class */ (function () {
|
|
|
1557
1594
|
this.cleanup();
|
|
1558
1595
|
// Reinitialize an artboard instance with the state
|
|
1559
1596
|
this.initArtboard(artBoardName, animationNames, stateMachineNames, autoplay);
|
|
1597
|
+
this.taskQueue.process();
|
|
1560
1598
|
};
|
|
1561
1599
|
// Loads a new Rive file, keeping listeners in place
|
|
1562
1600
|
Rive.prototype.load = function (params) {
|
|
@@ -1597,7 +1635,7 @@ var Rive = /** @class */ (function () {
|
|
|
1597
1635
|
minX: 0,
|
|
1598
1636
|
minY: 0,
|
|
1599
1637
|
maxX: this.canvas.width,
|
|
1600
|
-
maxY: this.canvas.height
|
|
1638
|
+
maxY: this.canvas.height,
|
|
1601
1639
|
});
|
|
1602
1640
|
};
|
|
1603
1641
|
/**
|
|
@@ -1703,9 +1741,7 @@ var Rive = /** @class */ (function () {
|
|
|
1703
1741
|
if (!this.loaded) {
|
|
1704
1742
|
return [];
|
|
1705
1743
|
}
|
|
1706
|
-
return this.animator.animations
|
|
1707
|
-
.filter(function (a) { return a.playing; })
|
|
1708
|
-
.map(function (a) { return a.name; });
|
|
1744
|
+
return this.animator.animations.filter(function (a) { return a.playing; }).map(function (a) { return a.name; });
|
|
1709
1745
|
},
|
|
1710
1746
|
enumerable: false,
|
|
1711
1747
|
configurable: true
|
|
@@ -1891,7 +1927,10 @@ var Rive = /** @class */ (function () {
|
|
|
1891
1927
|
var input = instance.input(l);
|
|
1892
1928
|
inputContents.push({ name: input.name, type: input.type });
|
|
1893
1929
|
}
|
|
1894
|
-
artboardContents.stateMachines.push({
|
|
1930
|
+
artboardContents.stateMachines.push({
|
|
1931
|
+
name: name_1,
|
|
1932
|
+
inputs: inputContents,
|
|
1933
|
+
});
|
|
1895
1934
|
}
|
|
1896
1935
|
riveContents.artboards.push(artboardContents);
|
|
1897
1936
|
}
|