@rive-app/webgl-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
|
@@ -176,7 +176,7 @@ k.run=xd;if(k.preInit)for("function"==typeof k.preInit&&(k.preInit=[k.preInit]);
|
|
|
176
176
|
/* 2 */
|
|
177
177
|
/***/ ((module) => {
|
|
178
178
|
|
|
179
|
-
module.exports = JSON.parse('{"name":"@rive-app/webgl-single","version":"1.0.
|
|
179
|
+
module.exports = JSON.parse('{"name":"@rive-app/webgl-single","version":"1.0.72","description":"Rive\'s webgl based web api with bundled wasm.","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}}');
|
|
180
180
|
|
|
181
181
|
/***/ }),
|
|
182
182
|
/* 3 */
|
|
@@ -212,56 +212,69 @@ const registerTouchInteractions = ({
|
|
|
212
212
|
alignment,
|
|
213
213
|
}) => {
|
|
214
214
|
if (!canvas || !stateMachines.length || !renderer || !rive || !artboard) {
|
|
215
|
-
return;
|
|
215
|
+
return null;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
const mouseCallback = (event) => {
|
|
219
|
+
const boundingRect = event.currentTarget.getBoundingClientRect();
|
|
220
220
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
const canvasX = event.clientX - boundingRect.left;
|
|
222
|
+
const canvasY = event.clientY - boundingRect.top;
|
|
223
|
+
const forwardMatrix = rive.computeAlignment(
|
|
224
|
+
fit,
|
|
225
|
+
alignment,
|
|
226
|
+
{
|
|
224
227
|
minX: 0,
|
|
225
228
|
minY: 0,
|
|
226
229
|
maxX: boundingRect.width,
|
|
227
230
|
maxY: boundingRect.height,
|
|
228
|
-
},
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
231
|
+
},
|
|
232
|
+
artboard.bounds
|
|
233
|
+
);
|
|
234
|
+
let invertedMatrix = new rive.Mat2D();
|
|
235
|
+
forwardMatrix.invert(invertedMatrix);
|
|
236
|
+
const canvasCoordinatesVector = new rive.Vec2D(canvasX, canvasY);
|
|
237
|
+
const transformedVector = rive.mapXY(
|
|
238
|
+
invertedMatrix,
|
|
239
|
+
canvasCoordinatesVector
|
|
240
|
+
);
|
|
241
|
+
const transformedX = transformedVector.x();
|
|
242
|
+
const transformedY = transformedVector.y();
|
|
235
243
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
break;
|
|
244
|
+
switch (event.type) {
|
|
245
|
+
// Pointer moving/hovering on the canvas
|
|
246
|
+
case 'mousemove': {
|
|
247
|
+
for (const stateMachine of stateMachines) {
|
|
248
|
+
stateMachine.pointerMove(transformedX, transformedY);
|
|
243
249
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
// Pointer click initiated but not released yet on the canvas
|
|
253
|
+
case 'mousedown': {
|
|
254
|
+
for (const stateMachine of stateMachines) {
|
|
255
|
+
stateMachine.pointerDown(transformedX, transformedY);
|
|
250
256
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
// Pointer click released on the canvas
|
|
260
|
+
case 'mouseup': {
|
|
261
|
+
for (const stateMachine of stateMachines) {
|
|
262
|
+
stateMachine.pointerUp(transformedX, transformedY);
|
|
257
263
|
}
|
|
258
|
-
|
|
264
|
+
break;
|
|
259
265
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
266
|
+
default:
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
const callback = mouseCallback.bind(undefined);
|
|
270
|
+
canvas.addEventListener('mousemove', callback);
|
|
271
|
+
canvas.addEventListener('mousedown', callback);
|
|
272
|
+
canvas.addEventListener('mouseup', callback);
|
|
273
|
+
return () => {
|
|
274
|
+
canvas.removeEventListener('mousemove', callback);
|
|
275
|
+
canvas.removeEventListener('mousedown', callback);
|
|
276
|
+
canvas.removeEventListener('mouseup', callback);
|
|
277
|
+
};
|
|
265
278
|
};
|
|
266
279
|
|
|
267
280
|
|
|
@@ -441,7 +454,7 @@ var Layout = /** @class */ (function () {
|
|
|
441
454
|
minX: minX !== null && minX !== void 0 ? minX : this.minX,
|
|
442
455
|
minY: minY !== null && minY !== void 0 ? minY : this.minY,
|
|
443
456
|
maxX: maxX !== null && maxX !== void 0 ? maxX : this.maxX,
|
|
444
|
-
maxY: maxY !== null && maxY !== void 0 ? maxY : this.maxY
|
|
457
|
+
maxY: maxY !== null && maxY !== void 0 ? maxY : this.maxY,
|
|
445
458
|
});
|
|
446
459
|
};
|
|
447
460
|
// Returns fit for the Wasm runtime format
|
|
@@ -505,7 +518,7 @@ var RuntimeLoader = /** @class */ (function () {
|
|
|
505
518
|
RuntimeLoader.loadRuntime = function () {
|
|
506
519
|
_rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__.default({
|
|
507
520
|
// Loads Wasm bundle
|
|
508
|
-
locateFile: function (_) { return RuntimeLoader.wasmURL; }
|
|
521
|
+
locateFile: function (_) { return RuntimeLoader.wasmURL; },
|
|
509
522
|
}).then(function (rive) {
|
|
510
523
|
var _a;
|
|
511
524
|
RuntimeLoader.runtime = rive;
|
|
@@ -806,8 +819,8 @@ var Animator = /** @class */ (function () {
|
|
|
806
819
|
animatables = mapToStringArray(animatables);
|
|
807
820
|
// If animatables is empty, play or pause everything
|
|
808
821
|
if (animatables.length === 0) {
|
|
809
|
-
this.animations.forEach(function (a) { return a.playing = playing; });
|
|
810
|
-
this.stateMachines.forEach(function (m) { return m.playing = playing; });
|
|
822
|
+
this.animations.forEach(function (a) { return (a.playing = playing); });
|
|
823
|
+
this.stateMachines.forEach(function (m) { return (m.playing = playing); });
|
|
811
824
|
}
|
|
812
825
|
else {
|
|
813
826
|
// Play/pause already instanced items, or create new instances
|
|
@@ -873,11 +886,11 @@ var Animator = /** @class */ (function () {
|
|
|
873
886
|
return this.add(animatables, true);
|
|
874
887
|
};
|
|
875
888
|
/**
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
889
|
+
* Pauses named animations and state machines, or everything if nothing is
|
|
890
|
+
* specified
|
|
891
|
+
* @param animatables names of the animations and state machines to pause
|
|
892
|
+
* @returns a list of names of the animations and state machines paused
|
|
893
|
+
*/
|
|
881
894
|
Animator.prototype.pause = function (animatables) {
|
|
882
895
|
return this.add(animatables, false);
|
|
883
896
|
};
|
|
@@ -888,8 +901,10 @@ var Animator = /** @class */ (function () {
|
|
|
888
901
|
* @returns a list of names of the animations that were scrubbed
|
|
889
902
|
*/
|
|
890
903
|
Animator.prototype.scrub = function (animatables, value) {
|
|
891
|
-
var forScrubbing = this.animations.filter(function (a) {
|
|
892
|
-
|
|
904
|
+
var forScrubbing = this.animations.filter(function (a) {
|
|
905
|
+
return animatables.includes(a.name);
|
|
906
|
+
});
|
|
907
|
+
forScrubbing.forEach(function (a) { return (a.scrubTo = value); });
|
|
893
908
|
return forScrubbing.map(function (a) { return a.name; });
|
|
894
909
|
};
|
|
895
910
|
Object.defineProperty(Animator.prototype, "playing", {
|
|
@@ -898,7 +913,10 @@ var Animator = /** @class */ (function () {
|
|
|
898
913
|
* playing
|
|
899
914
|
*/
|
|
900
915
|
get: function () {
|
|
901
|
-
return this.animations
|
|
916
|
+
return this.animations
|
|
917
|
+
.filter(function (a) { return a.playing; })
|
|
918
|
+
.map(function (a) { return a.name; })
|
|
919
|
+
.concat(this.stateMachines.filter(function (m) { return m.playing; }).map(function (m) { return m.name; }));
|
|
902
920
|
},
|
|
903
921
|
enumerable: false,
|
|
904
922
|
configurable: true
|
|
@@ -909,7 +927,10 @@ var Animator = /** @class */ (function () {
|
|
|
909
927
|
* paused
|
|
910
928
|
*/
|
|
911
929
|
get: function () {
|
|
912
|
-
return this.animations
|
|
930
|
+
return this.animations
|
|
931
|
+
.filter(function (a) { return !a.playing; })
|
|
932
|
+
.map(function (a) { return a.name; })
|
|
933
|
+
.concat(this.stateMachines.filter(function (m) { return !m.playing; }).map(function (m) { return m.name; }));
|
|
913
934
|
},
|
|
914
935
|
enumerable: false,
|
|
915
936
|
configurable: true
|
|
@@ -926,7 +947,9 @@ var Animator = /** @class */ (function () {
|
|
|
926
947
|
var removedNames = [];
|
|
927
948
|
// Stop everything
|
|
928
949
|
if (animatables.length === 0) {
|
|
929
|
-
removedNames = this.animations
|
|
950
|
+
removedNames = this.animations
|
|
951
|
+
.map(function (a) { return a.name; })
|
|
952
|
+
.concat(this.stateMachines.map(function (m) { return m.name; }));
|
|
930
953
|
// Clean up before emptying the arrays
|
|
931
954
|
this.animations.forEach(function (a) { return a.cleanup(); });
|
|
932
955
|
this.stateMachines.forEach(function (m) { return m.cleanup(); });
|
|
@@ -936,17 +959,23 @@ var Animator = /** @class */ (function () {
|
|
|
936
959
|
}
|
|
937
960
|
else {
|
|
938
961
|
// Remove only the named animations/state machines
|
|
939
|
-
var animationsToRemove = this.animations.filter(function (a) {
|
|
962
|
+
var animationsToRemove = this.animations.filter(function (a) {
|
|
963
|
+
return animatables.includes(a.name);
|
|
964
|
+
});
|
|
940
965
|
animationsToRemove.forEach(function (a) {
|
|
941
966
|
a.cleanup();
|
|
942
967
|
_this.animations.splice(_this.animations.indexOf(a), 1);
|
|
943
968
|
});
|
|
944
|
-
var machinesToRemove = this.stateMachines.filter(function (m) {
|
|
969
|
+
var machinesToRemove = this.stateMachines.filter(function (m) {
|
|
970
|
+
return animatables.includes(m.name);
|
|
971
|
+
});
|
|
945
972
|
machinesToRemove.forEach(function (m) {
|
|
946
973
|
m.cleanup();
|
|
947
974
|
_this.stateMachines.splice(_this.stateMachines.indexOf(m), 1);
|
|
948
975
|
});
|
|
949
|
-
removedNames = animationsToRemove
|
|
976
|
+
removedNames = animationsToRemove
|
|
977
|
+
.map(function (a) { return a.name; })
|
|
978
|
+
.concat(machinesToRemove.map(function (m) { return m.name; }));
|
|
950
979
|
}
|
|
951
980
|
this.eventManager.fire({
|
|
952
981
|
type: EventType.Stop,
|
|
@@ -960,8 +989,8 @@ var Animator = /** @class */ (function () {
|
|
|
960
989
|
* Returns true if at least one animation is active
|
|
961
990
|
*/
|
|
962
991
|
get: function () {
|
|
963
|
-
return this.animations.reduce(function (acc, curr) { return acc || curr.playing; }, false)
|
|
964
|
-
|
|
992
|
+
return (this.animations.reduce(function (acc, curr) { return acc || curr.playing; }, false) ||
|
|
993
|
+
this.stateMachines.reduce(function (acc, curr) { return acc || curr.playing; }, false));
|
|
965
994
|
},
|
|
966
995
|
enumerable: false,
|
|
967
996
|
configurable: true
|
|
@@ -971,8 +1000,8 @@ var Animator = /** @class */ (function () {
|
|
|
971
1000
|
* Returns true if all animations are paused and there's at least one animation
|
|
972
1001
|
*/
|
|
973
1002
|
get: function () {
|
|
974
|
-
return !this.isPlaying &&
|
|
975
|
-
(this.animations.length > 0 || this.stateMachines.length > 0);
|
|
1003
|
+
return (!this.isPlaying &&
|
|
1004
|
+
(this.animations.length > 0 || this.stateMachines.length > 0));
|
|
976
1005
|
},
|
|
977
1006
|
enumerable: false,
|
|
978
1007
|
configurable: true
|
|
@@ -997,11 +1026,11 @@ var Animator = /** @class */ (function () {
|
|
|
997
1026
|
if (this.animations.length === 0 && this.stateMachines.length === 0) {
|
|
998
1027
|
if (this.artboard.animationCount() > 0) {
|
|
999
1028
|
// Add the first animation
|
|
1000
|
-
this.add([instancedName = this.artboard.animationByIndex(0).name], playing, fireEvent);
|
|
1029
|
+
this.add([(instancedName = this.artboard.animationByIndex(0).name)], playing, fireEvent);
|
|
1001
1030
|
}
|
|
1002
1031
|
else if (this.artboard.stateMachineCount() > 0) {
|
|
1003
1032
|
// Add the first state machine
|
|
1004
|
-
this.add([instancedName = this.artboard.stateMachineByIndex(0).name], playing, fireEvent);
|
|
1033
|
+
this.add([(instancedName = this.artboard.stateMachineByIndex(0).name)], playing, fireEvent);
|
|
1005
1034
|
}
|
|
1006
1035
|
}
|
|
1007
1036
|
return instancedName;
|
|
@@ -1021,7 +1050,7 @@ var Animator = /** @class */ (function () {
|
|
|
1021
1050
|
else if (animation.loopValue === 1 && animation.loopCount) {
|
|
1022
1051
|
this.eventManager.fire({
|
|
1023
1052
|
type: EventType.Loop,
|
|
1024
|
-
data: { animation: animation.name, type: LoopType.Loop }
|
|
1053
|
+
data: { animation: animation.name, type: LoopType.Loop },
|
|
1025
1054
|
});
|
|
1026
1055
|
animation.loopCount = 0;
|
|
1027
1056
|
}
|
|
@@ -1031,7 +1060,7 @@ var Animator = /** @class */ (function () {
|
|
|
1031
1060
|
else if (animation.loopValue === 2 && animation.loopCount > 1) {
|
|
1032
1061
|
this.eventManager.fire({
|
|
1033
1062
|
type: EventType.Loop,
|
|
1034
|
-
data: { animation: animation.name, type: LoopType.PingPong }
|
|
1063
|
+
data: { animation: animation.name, type: LoopType.PingPong },
|
|
1035
1064
|
});
|
|
1036
1065
|
animation.loopCount = 0;
|
|
1037
1066
|
}
|
|
@@ -1079,7 +1108,7 @@ var LoopType;
|
|
|
1079
1108
|
(function (LoopType) {
|
|
1080
1109
|
LoopType["OneShot"] = "oneshot";
|
|
1081
1110
|
LoopType["Loop"] = "loop";
|
|
1082
|
-
LoopType["PingPong"] = "pingpong";
|
|
1111
|
+
LoopType["PingPong"] = "pingpong";
|
|
1083
1112
|
})(LoopType || (LoopType = {}));
|
|
1084
1113
|
// Manages Rive events and listeners
|
|
1085
1114
|
var EventManager = /** @class */ (function () {
|
|
@@ -1183,6 +1212,8 @@ var Rive = /** @class */ (function () {
|
|
|
1183
1212
|
this.readyForPlaying = false;
|
|
1184
1213
|
// Runtime artboard
|
|
1185
1214
|
this.artboard = null;
|
|
1215
|
+
// place to clear up event listeners
|
|
1216
|
+
this.eventCleanup = null;
|
|
1186
1217
|
// Durations to generate a frame for the last second. Used for performance profiling.
|
|
1187
1218
|
this.durations = [];
|
|
1188
1219
|
this.frameTimes = [];
|
|
@@ -1263,7 +1294,8 @@ var Rive = /** @class */ (function () {
|
|
|
1263
1294
|
this.loaded = false;
|
|
1264
1295
|
this.readyForPlaying = false;
|
|
1265
1296
|
// Ensure the runtime is loaded
|
|
1266
|
-
RuntimeLoader.awaitInstance()
|
|
1297
|
+
RuntimeLoader.awaitInstance()
|
|
1298
|
+
.then(function (runtime) {
|
|
1267
1299
|
_this.runtime = runtime;
|
|
1268
1300
|
// Get the canvas where you want to render the animation and create a renderer
|
|
1269
1301
|
_this.renderer = _this.runtime.makeRenderer(_this.canvas, useOffscreenRenderer);
|
|
@@ -1277,7 +1309,7 @@ var Rive = /** @class */ (function () {
|
|
|
1277
1309
|
var activeStateMachineInstances = (_this.animator.stateMachines || [])
|
|
1278
1310
|
.filter(function (sm) { return sm.playing; })
|
|
1279
1311
|
.map(function (sm) { return sm.instance; });
|
|
1280
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
|
|
1312
|
+
_this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
|
|
1281
1313
|
canvas: _this.canvas,
|
|
1282
1314
|
artboard: _this.artboard,
|
|
1283
1315
|
stateMachines: activeStateMachineInstances,
|
|
@@ -1290,7 +1322,8 @@ var Rive = /** @class */ (function () {
|
|
|
1290
1322
|
.catch(function (e) {
|
|
1291
1323
|
console.error(e);
|
|
1292
1324
|
});
|
|
1293
|
-
})
|
|
1325
|
+
})
|
|
1326
|
+
.catch(function (e) {
|
|
1294
1327
|
console.error(e);
|
|
1295
1328
|
});
|
|
1296
1329
|
};
|
|
@@ -1322,7 +1355,7 @@ var Rive = /** @class */ (function () {
|
|
|
1322
1355
|
this.loaded = true;
|
|
1323
1356
|
this.eventManager.fire({
|
|
1324
1357
|
type: EventType.Load,
|
|
1325
|
-
data: (_a = this.src) !== null && _a !== void 0 ? _a : 'buffer'
|
|
1358
|
+
data: (_a = this.src) !== null && _a !== void 0 ? _a : 'buffer',
|
|
1326
1359
|
});
|
|
1327
1360
|
// Flag ready for playback commands and clear the task queue; this order
|
|
1328
1361
|
// is important or it may infinitely recurse
|
|
@@ -1345,9 +1378,9 @@ var Rive = /** @class */ (function () {
|
|
|
1345
1378
|
// Initialize for playback
|
|
1346
1379
|
Rive.prototype.initArtboard = function (artboardName, animationNames, stateMachineNames, autoplay) {
|
|
1347
1380
|
// Fetch the artboard
|
|
1348
|
-
var rootArtboard = artboardName
|
|
1349
|
-
this.file.artboardByName(artboardName)
|
|
1350
|
-
this.file.defaultArtboard();
|
|
1381
|
+
var rootArtboard = artboardName
|
|
1382
|
+
? this.file.artboardByName(artboardName)
|
|
1383
|
+
: this.file.defaultArtboard();
|
|
1351
1384
|
// Check we have a working artboard
|
|
1352
1385
|
if (!rootArtboard) {
|
|
1353
1386
|
var msg = 'Invalid artboard name or no default artboard';
|
|
@@ -1382,7 +1415,7 @@ var Rive = /** @class */ (function () {
|
|
|
1382
1415
|
event: {
|
|
1383
1416
|
type: autoplay ? EventType.Play : EventType.Pause,
|
|
1384
1417
|
data: instanceNames,
|
|
1385
|
-
}
|
|
1418
|
+
},
|
|
1386
1419
|
});
|
|
1387
1420
|
};
|
|
1388
1421
|
// Draws the current artboard frame
|
|
@@ -1402,7 +1435,7 @@ var Rive = /** @class */ (function () {
|
|
|
1402
1435
|
this.lastRenderTime = time;
|
|
1403
1436
|
}
|
|
1404
1437
|
// Handle the onSecond callback
|
|
1405
|
-
this.renderSecondTimer +=
|
|
1438
|
+
this.renderSecondTimer += time - this.lastRenderTime;
|
|
1406
1439
|
if (this.renderSecondTimer > 5000) {
|
|
1407
1440
|
this.renderSecondTimer = 0;
|
|
1408
1441
|
onSecond === null || onSecond === void 0 ? void 0 : onSecond();
|
|
@@ -1413,10 +1446,11 @@ var Rive = /** @class */ (function () {
|
|
|
1413
1446
|
// - Advance non-paused animations by the elapsed number of seconds
|
|
1414
1447
|
// - Advance any animations that require scrubbing
|
|
1415
1448
|
// - Advance to the first frame even when autoplay is false
|
|
1416
|
-
var activeAnimations = this.animator.animations
|
|
1449
|
+
var activeAnimations = this.animator.animations
|
|
1450
|
+
.filter(function (a) { return a.playing || a.needsScrub; })
|
|
1417
1451
|
// The scrubbed animations must be applied first to prevent weird artifacts
|
|
1418
1452
|
// if the playing animations conflict with the scrubbed animating attribuates.
|
|
1419
|
-
.sort(function (first, second) { return first.needsScrub ? -1 : 1; });
|
|
1453
|
+
.sort(function (first, second) { return (first.needsScrub ? -1 : 1); });
|
|
1420
1454
|
for (var _i = 0, activeAnimations_1 = activeAnimations; _i < activeAnimations_1.length; _i++) {
|
|
1421
1455
|
var animation = activeAnimations_1[_i];
|
|
1422
1456
|
animation.advance(elapsedTime);
|
|
@@ -1486,7 +1520,7 @@ var Rive = /** @class */ (function () {
|
|
|
1486
1520
|
minX: _layout.minX,
|
|
1487
1521
|
minY: _layout.minY,
|
|
1488
1522
|
maxX: _layout.maxX,
|
|
1489
|
-
maxY: _layout.maxY
|
|
1523
|
+
maxY: _layout.maxY,
|
|
1490
1524
|
}, artboard.bounds);
|
|
1491
1525
|
};
|
|
1492
1526
|
Object.defineProperty(Rive.prototype, "fps", {
|
|
@@ -1514,6 +1548,9 @@ var Rive = /** @class */ (function () {
|
|
|
1514
1548
|
* might happen.
|
|
1515
1549
|
*/
|
|
1516
1550
|
Rive.prototype.cleanup = function () {
|
|
1551
|
+
if (this.eventCleanup !== null) {
|
|
1552
|
+
this.eventCleanup();
|
|
1553
|
+
}
|
|
1517
1554
|
this.artboard.delete();
|
|
1518
1555
|
// TODO: delete animation and state machine instances
|
|
1519
1556
|
};
|
|
@@ -1592,6 +1629,7 @@ var Rive = /** @class */ (function () {
|
|
|
1592
1629
|
this.cleanup();
|
|
1593
1630
|
// Reinitialize an artboard instance with the state
|
|
1594
1631
|
this.initArtboard(artBoardName, animationNames, stateMachineNames, autoplay);
|
|
1632
|
+
this.taskQueue.process();
|
|
1595
1633
|
};
|
|
1596
1634
|
// Loads a new Rive file, keeping listeners in place
|
|
1597
1635
|
Rive.prototype.load = function (params) {
|
|
@@ -1632,7 +1670,7 @@ var Rive = /** @class */ (function () {
|
|
|
1632
1670
|
minX: 0,
|
|
1633
1671
|
minY: 0,
|
|
1634
1672
|
maxX: this.canvas.width,
|
|
1635
|
-
maxY: this.canvas.height
|
|
1673
|
+
maxY: this.canvas.height,
|
|
1636
1674
|
});
|
|
1637
1675
|
};
|
|
1638
1676
|
/**
|
|
@@ -1738,9 +1776,7 @@ var Rive = /** @class */ (function () {
|
|
|
1738
1776
|
if (!this.loaded) {
|
|
1739
1777
|
return [];
|
|
1740
1778
|
}
|
|
1741
|
-
return this.animator.animations
|
|
1742
|
-
.filter(function (a) { return a.playing; })
|
|
1743
|
-
.map(function (a) { return a.name; });
|
|
1779
|
+
return this.animator.animations.filter(function (a) { return a.playing; }).map(function (a) { return a.name; });
|
|
1744
1780
|
},
|
|
1745
1781
|
enumerable: false,
|
|
1746
1782
|
configurable: true
|
|
@@ -1926,7 +1962,10 @@ var Rive = /** @class */ (function () {
|
|
|
1926
1962
|
var input = instance.input(l);
|
|
1927
1963
|
inputContents.push({ name: input.name, type: input.type });
|
|
1928
1964
|
}
|
|
1929
|
-
artboardContents.stateMachines.push({
|
|
1965
|
+
artboardContents.stateMachines.push({
|
|
1966
|
+
name: name_1,
|
|
1967
|
+
inputs: inputContents,
|
|
1968
|
+
});
|
|
1930
1969
|
}
|
|
1931
1970
|
riveContents.artboards.push(artboardContents);
|
|
1932
1971
|
}
|