@rive-app/canvas-single 1.0.66 → 1.0.67

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/rive.js +32 -8
  3. package/rive.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/canvas-single",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
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.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.66","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}}');
144
+ module.exports = JSON.parse('{"name":"@rive-app/canvas-single","version":"1.0.67","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 */
@@ -577,6 +577,16 @@ var Animation = /** @class */ (function () {
577
577
  this.scrubTo = null;
578
578
  }
579
579
  };
580
+ /**
581
+ * Apply interpolated keyframe values to the artboard. This should be called after calling
582
+ * .advance() on an animation instance so that new values are applied to properties.
583
+ *
584
+ * Note: This does not advance the artboard, which updates all objects on the artboard
585
+ * @param mix - Mix value for the animation from 0 to 1
586
+ */
587
+ Animation.prototype.apply = function (mix) {
588
+ this.instance.apply(mix);
589
+ };
580
590
  Object.defineProperty(Animation.prototype, "needsScrub", {
581
591
  get: function () {
582
592
  return this.scrubTo !== null;
@@ -684,6 +694,13 @@ var StateMachine = /** @class */ (function () {
684
694
  enumerable: false,
685
695
  configurable: true
686
696
  });
697
+ /**
698
+ * Advances the state machine instance by a given time.
699
+ * @param time - the time to advance the animation by in seconds
700
+ */
701
+ StateMachine.prototype.advance = function (time) {
702
+ this.instance.advance(time);
703
+ };
687
704
  /**
688
705
  * Fetches references to the state machine's inputs and caches them
689
706
  * @param runtime an instance of the runtime; needed for the SMIInput types
@@ -778,13 +795,18 @@ var Animator = /** @class */ (function () {
778
795
  // Try to create a new animation instance
779
796
  var anim = this.artboard.animationByName(animatables[i]);
780
797
  if (anim) {
781
- this.animations.push(new Animation(anim, this.artboard, this.runtime, playing));
798
+ var newAnimation = new Animation(anim, this.artboard, this.runtime, playing);
799
+ // Display the first frame of the specified animation
800
+ newAnimation.advance(0);
801
+ newAnimation.apply(1.0);
802
+ this.animations.push(newAnimation);
782
803
  }
783
804
  else {
784
805
  // Try to create a new state machine instance
785
806
  var sm = this.artboard.stateMachineByName(animatables[i]);
786
807
  if (sm) {
787
- this.stateMachines.push(new StateMachine(sm, this.runtime, playing, this.artboard));
808
+ var newStateMachine = new StateMachine(sm, this.runtime, playing, this.artboard);
809
+ this.stateMachines.push(newStateMachine);
788
810
  }
789
811
  }
790
812
  }
@@ -1353,8 +1375,9 @@ var Rive = /** @class */ (function () {
1353
1375
  // Calculate the elapsed time between frames in seconds
1354
1376
  var elapsedTime = (time - this.lastRenderTime) / 1000;
1355
1377
  this.lastRenderTime = time;
1356
- // Advance non-paused animations by the elapsed number of seconds
1357
- // Also advance any animations that require scrubbing
1378
+ // - Advance non-paused animations by the elapsed number of seconds
1379
+ // - Advance any animations that require scrubbing
1380
+ // - Advance to the first frame even when autoplay is false
1358
1381
  var activeAnimations = this.animator.animations.filter(function (a) { return a.playing || a.needsScrub; })
1359
1382
  // The scrubbed animations must be applied first to prevent weird artifacts
1360
1383
  // if the playing animations conflict with the scrubbed animating attribuates.
@@ -1365,13 +1388,14 @@ var Rive = /** @class */ (function () {
1365
1388
  if (animation.instance.didLoop) {
1366
1389
  animation.loopCount += 1;
1367
1390
  }
1368
- animation.instance.apply(1.0);
1391
+ animation.apply(1.0);
1369
1392
  }
1370
- // Advance non-paused state machines by the elapsed number of seconds
1393
+ // - Advance non-paused state machines by the elapsed number of seconds
1394
+ // - Advance to the first frame even when autoplay is false
1371
1395
  var activeStateMachines = this.animator.stateMachines.filter(function (a) { return a.playing; });
1372
1396
  for (var _a = 0, activeStateMachines_1 = activeStateMachines; _a < activeStateMachines_1.length; _a++) {
1373
1397
  var stateMachine = activeStateMachines_1[_a];
1374
- stateMachine.instance.advance(elapsedTime);
1398
+ stateMachine.advance(elapsedTime);
1375
1399
  // stateMachine.instance.apply(this.artboard);
1376
1400
  }
1377
1401
  // Once the animations have been applied to the artboard, advance it