@rive-app/canvas-single 1.1.4 → 1.1.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/canvas-single",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Rive's high-level canvas based web api all in one js file.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.d.ts CHANGED
@@ -268,12 +268,14 @@ export declare class Rive {
268
268
  private taskQueue;
269
269
  private animator;
270
270
  private static readonly missingErrorMessage;
271
+ private shouldDisableRiveListeners;
271
272
  durations: number[];
272
273
  frameTimes: number[];
273
274
  frameCount: number;
274
275
  constructor(params: RiveParameters);
275
276
  static new(params: RiveParameters): Rive;
276
277
  private init;
278
+ private setupRiveListeners;
277
279
  private initData;
278
280
  private initArtboard;
279
281
  drawFrame(): void;
package/rive.js CHANGED
@@ -134,7 +134,7 @@ if(m.preInit)for("function"==typeof m.preInit&&(m.preInit=[m.preInit]);0<m.preIn
134
134
  /* 2 */
135
135
  /***/ ((module) => {
136
136
 
137
- module.exports = JSON.parse('{"name":"@rive-app/canvas-single","version":"1.1.4","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}}');
137
+ module.exports = JSON.parse('{"name":"@rive-app/canvas-single","version":"1.1.5","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}}');
138
138
 
139
139
  /***/ }),
140
140
  /* 3 */
@@ -1211,6 +1211,7 @@ var Rive = /** @class */ (function () {
1211
1211
  this.artboard = null;
1212
1212
  // place to clear up event listeners
1213
1213
  this.eventCleanup = null;
1214
+ this.shouldDisableRiveListeners = false;
1214
1215
  // Durations to generate a frame for the last second. Used for performance profiling.
1215
1216
  this.durations = [];
1216
1217
  this.frameTimes = [];
@@ -1224,6 +1225,7 @@ var Rive = /** @class */ (function () {
1224
1225
  this.src = params.src;
1225
1226
  this.buffer = params.buffer;
1226
1227
  this.layout = (_a = params.layout) !== null && _a !== void 0 ? _a : new Layout();
1228
+ this.shouldDisableRiveListeners = !!params.shouldDisableRiveListeners;
1227
1229
  // New event management system
1228
1230
  this.eventManager = new EventManager();
1229
1231
  if (params.onLoad)
@@ -1267,7 +1269,6 @@ var Rive = /** @class */ (function () {
1267
1269
  stateMachines: params.stateMachines,
1268
1270
  artboard: params.artboard,
1269
1271
  useOffscreenRenderer: params.useOffscreenRenderer,
1270
- shouldDisableRiveListeners: params.shouldDisableRiveListeners,
1271
1272
  });
1272
1273
  }
1273
1274
  // Alternative constructor to build a Rive instance from an interface/object
@@ -1278,7 +1279,7 @@ var Rive = /** @class */ (function () {
1278
1279
  // Initializes the Rive object either from constructor or load()
1279
1280
  Rive.prototype.init = function (_a) {
1280
1281
  var _this = this;
1281
- var src = _a.src, buffer = _a.buffer, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c, _d = _a.shouldDisableRiveListeners, shouldDisableRiveListeners = _d === void 0 ? false : _d;
1282
+ var src = _a.src, buffer = _a.buffer, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c;
1282
1283
  this.src = src;
1283
1284
  this.buffer = buffer;
1284
1285
  // If no source file url specified, it's a bust
@@ -1305,22 +1306,7 @@ var Rive = /** @class */ (function () {
1305
1306
  }
1306
1307
  // Load Rive data from a source uri or a data buffer
1307
1308
  _this.initData(artboard, startingAnimationNames, startingStateMachineNames, autoplay)
1308
- .then(function () {
1309
- if (!shouldDisableRiveListeners) {
1310
- var activeStateMachines = (_this.animator.stateMachines || [])
1311
- .filter(function (sm) { return sm.playing && _this.runtime.hasListeners(sm.instance); })
1312
- .map(function (sm) { return sm.instance; });
1313
- _this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
1314
- canvas: _this.canvas,
1315
- artboard: _this.artboard,
1316
- stateMachines: activeStateMachines,
1317
- renderer: _this.renderer,
1318
- rive: _this.runtime,
1319
- fit: _this._layout.runtimeFit(_this.runtime),
1320
- alignment: _this._layout.runtimeAlignment(_this.runtime),
1321
- });
1322
- }
1323
- })
1309
+ .then(function () { return _this.setupRiveListeners(); })
1324
1310
  .catch(function (e) {
1325
1311
  console.error(e);
1326
1312
  });
@@ -1329,6 +1315,23 @@ var Rive = /** @class */ (function () {
1329
1315
  console.error(e);
1330
1316
  });
1331
1317
  };
1318
+ Rive.prototype.setupRiveListeners = function () {
1319
+ var _this = this;
1320
+ if (!this.shouldDisableRiveListeners) {
1321
+ var activeStateMachines = (this.animator.stateMachines || [])
1322
+ .filter(function (sm) { return sm.playing && _this.runtime.hasListeners(sm.instance); })
1323
+ .map(function (sm) { return sm.instance; });
1324
+ this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
1325
+ canvas: this.canvas,
1326
+ artboard: this.artboard,
1327
+ stateMachines: activeStateMachines,
1328
+ renderer: this.renderer,
1329
+ rive: this.runtime,
1330
+ fit: this._layout.runtimeFit(this.runtime),
1331
+ alignment: this._layout.runtimeAlignment(this.runtime),
1332
+ });
1333
+ }
1334
+ };
1332
1335
  // Initializes runtime with Rive data and preps for playing
1333
1336
  Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay) {
1334
1337
  var _a;
@@ -1592,6 +1595,10 @@ var Rive = /** @class */ (function () {
1592
1595
  return;
1593
1596
  }
1594
1597
  this.animator.play(animationNames);
1598
+ if (this.eventCleanup) {
1599
+ this.eventCleanup();
1600
+ }
1601
+ this.setupRiveListeners();
1595
1602
  this.startRendering();
1596
1603
  };
1597
1604
  // Pauses specified animations; if none specified, pauses all.
@@ -1634,6 +1641,9 @@ var Rive = /** @class */ (function () {
1634
1641
  return;
1635
1642
  }
1636
1643
  this.animator.stop(animationNames);
1644
+ if (this.eventCleanup) {
1645
+ this.eventCleanup();
1646
+ }
1637
1647
  };
1638
1648
  /**
1639
1649
  * Resets the animation