@rive-app/canvas-lite 2.34.0 → 2.34.2

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-lite",
3
- "version": "2.34.0",
3
+ "version": "2.34.2",
4
4
  "description": "A lite version of Rive's canvas based web api.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.d.ts CHANGED
@@ -429,6 +429,8 @@ export declare class Rive {
429
429
  private _devicePixelRatioUsed;
430
430
  private _hasZeroSize;
431
431
  private _needsRedraw;
432
+ private _currentCanvasWidth;
433
+ private _currentCanvasHeight;
432
434
  private _audioEventListener;
433
435
  private _boundDraw;
434
436
  private _viewModelInstance;
@@ -464,6 +466,7 @@ export declare class Rive {
464
466
  private initData;
465
467
  private initArtboard;
466
468
  drawFrame(): void;
469
+ private _canvasSizeChanged;
467
470
  private lastRenderTime;
468
471
  private frameRequestId;
469
472
  /**
package/rive.js CHANGED
@@ -2202,7 +2202,7 @@ moduleRtn = ca;
2202
2202
  /* 2 */
2203
2203
  /***/ ((module) => {
2204
2204
 
2205
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.34.0","description":"A lite version of Rive\'s canvas based web api.","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.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
2205
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.34.2","description":"A lite version of Rive\'s canvas based web api.","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.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
2206
2206
 
2207
2207
  /***/ }),
2208
2208
  /* 3 */
@@ -4547,6 +4547,10 @@ var Rive = /** @class */ (function () {
4547
4547
  this._hasZeroSize = false;
4548
4548
  // Whether a draw operation needs to be forced
4549
4549
  this._needsRedraw = false;
4550
+ // Canvas width and height. Values are lazily updated so they might
4551
+ // not be in sync with current canvas size.
4552
+ this._currentCanvasWidth = 0;
4553
+ this._currentCanvasHeight = 0;
4550
4554
  // Audio event listener
4551
4555
  this._audioEventListener = null;
4552
4556
  // draw method bound to the class
@@ -4581,6 +4585,8 @@ var Rive = /** @class */ (function () {
4581
4585
  if (params.canvas.constructor === HTMLCanvasElement) {
4582
4586
  this._observed = observers.add(this.canvas, this.onCanvasResize);
4583
4587
  }
4588
+ this._currentCanvasWidth = this.canvas.width;
4589
+ this._currentCanvasHeight = this.canvas.height;
4584
4590
  this.src = params.src;
4585
4591
  this.buffer = params.buffer;
4586
4592
  this.riveFile = params.riveFile;
@@ -4921,6 +4927,20 @@ var Rive = /** @class */ (function () {
4921
4927
  this.scheduleRendering();
4922
4928
  }
4923
4929
  };
4930
+ Rive.prototype._canvasSizeChanged = function () {
4931
+ var changed = false;
4932
+ if (this.canvas) {
4933
+ if (this.canvas.width !== this._currentCanvasWidth) {
4934
+ this._currentCanvasWidth = this.canvas.width;
4935
+ changed = true;
4936
+ }
4937
+ if (this.canvas.height !== this._currentCanvasHeight) {
4938
+ this._currentCanvasHeight = this.canvas.height;
4939
+ changed = true;
4940
+ }
4941
+ }
4942
+ return changed;
4943
+ };
4924
4944
  /**
4925
4945
  * Draw rendering loop; renders animation frames at the correct time interval.
4926
4946
  * @param time the time at which to render a frame
@@ -5009,7 +5029,9 @@ var Rive = /** @class */ (function () {
5009
5029
  if (!this._hasZeroSize) {
5010
5030
  // If there was no dirt on this frame, do not clear and draw
5011
5031
  if (this.drawOptimization == DrawOptimizationOptions.AlwaysDraw ||
5012
- this.artboard.didChange() || this._needsRedraw) {
5032
+ this.artboard.didChange() ||
5033
+ this._needsRedraw ||
5034
+ this._canvasSizeChanged()) {
5013
5035
  // Canvas must be wiped to prevent artifacts
5014
5036
  renderer.clear();
5015
5037
  renderer.save();
@@ -5640,7 +5662,8 @@ var Rive = /** @class */ (function () {
5640
5662
  * @returns true if no animations are playing or paused
5641
5663
  */
5642
5664
  get: function () {
5643
- return this.animator.isStopped;
5665
+ var _a, _b;
5666
+ return (_b = (_a = this.animator) === null || _a === void 0 ? void 0 : _a.isStopped) !== null && _b !== void 0 ? _b : true;
5644
5667
  },
5645
5668
  enumerable: false,
5646
5669
  configurable: true