@rive-app/webgl 2.34.0 → 2.34.1

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/webgl",
3
- "version": "2.34.0",
3
+ "version": "2.34.1",
4
4
  "description": "Rive's webgl 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
@@ -3935,7 +3935,7 @@ moduleRtn = ca;
3935
3935
  /* 2 */
3936
3936
  /***/ ((module) => {
3937
3937
 
3938
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.34.0","description":"Rive\'s webgl 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.wasm","rive_fallback.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3938
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.34.1","description":"Rive\'s webgl 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.wasm","rive_fallback.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3939
3939
 
3940
3940
  /***/ }),
3941
3941
  /* 3 */
@@ -6280,6 +6280,10 @@ var Rive = /** @class */ (function () {
6280
6280
  this._hasZeroSize = false;
6281
6281
  // Whether a draw operation needs to be forced
6282
6282
  this._needsRedraw = false;
6283
+ // Canvas width and height. Values are lazily updated so they might
6284
+ // not be in sync with current canvas size.
6285
+ this._currentCanvasWidth = 0;
6286
+ this._currentCanvasHeight = 0;
6283
6287
  // Audio event listener
6284
6288
  this._audioEventListener = null;
6285
6289
  // draw method bound to the class
@@ -6314,6 +6318,8 @@ var Rive = /** @class */ (function () {
6314
6318
  if (params.canvas.constructor === HTMLCanvasElement) {
6315
6319
  this._observed = observers.add(this.canvas, this.onCanvasResize);
6316
6320
  }
6321
+ this._currentCanvasWidth = this.canvas.width;
6322
+ this._currentCanvasHeight = this.canvas.height;
6317
6323
  this.src = params.src;
6318
6324
  this.buffer = params.buffer;
6319
6325
  this.riveFile = params.riveFile;
@@ -6654,6 +6660,20 @@ var Rive = /** @class */ (function () {
6654
6660
  this.scheduleRendering();
6655
6661
  }
6656
6662
  };
6663
+ Rive.prototype._canvasSizeChanged = function () {
6664
+ var changed = false;
6665
+ if (this.canvas) {
6666
+ if (this.canvas.width !== this._currentCanvasWidth) {
6667
+ this._currentCanvasWidth = this.canvas.width;
6668
+ changed = true;
6669
+ }
6670
+ if (this.canvas.height !== this._currentCanvasHeight) {
6671
+ this._currentCanvasHeight = this.canvas.height;
6672
+ changed = true;
6673
+ }
6674
+ }
6675
+ return changed;
6676
+ };
6657
6677
  /**
6658
6678
  * Draw rendering loop; renders animation frames at the correct time interval.
6659
6679
  * @param time the time at which to render a frame
@@ -6742,7 +6762,9 @@ var Rive = /** @class */ (function () {
6742
6762
  if (!this._hasZeroSize) {
6743
6763
  // If there was no dirt on this frame, do not clear and draw
6744
6764
  if (this.drawOptimization == DrawOptimizationOptions.AlwaysDraw ||
6745
- this.artboard.didChange() || this._needsRedraw) {
6765
+ this.artboard.didChange() ||
6766
+ this._needsRedraw ||
6767
+ this._canvasSizeChanged()) {
6746
6768
  // Canvas must be wiped to prevent artifacts
6747
6769
  renderer.clear();
6748
6770
  renderer.save();
@@ -7373,7 +7395,8 @@ var Rive = /** @class */ (function () {
7373
7395
  * @returns true if no animations are playing or paused
7374
7396
  */
7375
7397
  get: function () {
7376
- return this.animator.isStopped;
7398
+ var _a, _b;
7399
+ return (_b = (_a = this.animator) === null || _a === void 0 ? void 0 : _a.isStopped) !== null && _b !== void 0 ? _b : true;
7377
7400
  },
7378
7401
  enumerable: false,
7379
7402
  configurable: true