@rive-app/webgl2 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/webgl2",
3
- "version": "2.34.0",
3
+ "version": "2.34.1",
4
4
  "description": "Rive's webgl2 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
@@ -3546,7 +3546,7 @@ moduleRtn = ca;
3546
3546
  /* 2 */
3547
3547
  /***/ ((module) => {
3548
3548
 
3549
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.34.0","description":"Rive\'s webgl2 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)","Chris Dalton <chris@rive.app> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3549
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.34.1","description":"Rive\'s webgl2 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)","Chris Dalton <chris@rive.app> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3550
3550
 
3551
3551
  /***/ }),
3552
3552
  /* 3 */
@@ -5891,6 +5891,10 @@ var Rive = /** @class */ (function () {
5891
5891
  this._hasZeroSize = false;
5892
5892
  // Whether a draw operation needs to be forced
5893
5893
  this._needsRedraw = false;
5894
+ // Canvas width and height. Values are lazily updated so they might
5895
+ // not be in sync with current canvas size.
5896
+ this._currentCanvasWidth = 0;
5897
+ this._currentCanvasHeight = 0;
5894
5898
  // Audio event listener
5895
5899
  this._audioEventListener = null;
5896
5900
  // draw method bound to the class
@@ -5925,6 +5929,8 @@ var Rive = /** @class */ (function () {
5925
5929
  if (params.canvas.constructor === HTMLCanvasElement) {
5926
5930
  this._observed = observers.add(this.canvas, this.onCanvasResize);
5927
5931
  }
5932
+ this._currentCanvasWidth = this.canvas.width;
5933
+ this._currentCanvasHeight = this.canvas.height;
5928
5934
  this.src = params.src;
5929
5935
  this.buffer = params.buffer;
5930
5936
  this.riveFile = params.riveFile;
@@ -6265,6 +6271,20 @@ var Rive = /** @class */ (function () {
6265
6271
  this.scheduleRendering();
6266
6272
  }
6267
6273
  };
6274
+ Rive.prototype._canvasSizeChanged = function () {
6275
+ var changed = false;
6276
+ if (this.canvas) {
6277
+ if (this.canvas.width !== this._currentCanvasWidth) {
6278
+ this._currentCanvasWidth = this.canvas.width;
6279
+ changed = true;
6280
+ }
6281
+ if (this.canvas.height !== this._currentCanvasHeight) {
6282
+ this._currentCanvasHeight = this.canvas.height;
6283
+ changed = true;
6284
+ }
6285
+ }
6286
+ return changed;
6287
+ };
6268
6288
  /**
6269
6289
  * Draw rendering loop; renders animation frames at the correct time interval.
6270
6290
  * @param time the time at which to render a frame
@@ -6353,7 +6373,9 @@ var Rive = /** @class */ (function () {
6353
6373
  if (!this._hasZeroSize) {
6354
6374
  // If there was no dirt on this frame, do not clear and draw
6355
6375
  if (this.drawOptimization == DrawOptimizationOptions.AlwaysDraw ||
6356
- this.artboard.didChange() || this._needsRedraw) {
6376
+ this.artboard.didChange() ||
6377
+ this._needsRedraw ||
6378
+ this._canvasSizeChanged()) {
6357
6379
  // Canvas must be wiped to prevent artifacts
6358
6380
  renderer.clear();
6359
6381
  renderer.save();
@@ -6984,7 +7006,8 @@ var Rive = /** @class */ (function () {
6984
7006
  * @returns true if no animations are playing or paused
6985
7007
  */
6986
7008
  get: function () {
6987
- return this.animator.isStopped;
7009
+ var _a, _b;
7010
+ return (_b = (_a = this.animator) === null || _a === void 0 ? void 0 : _a.isStopped) !== null && _b !== void 0 ? _b : true;
6988
7011
  },
6989
7012
  enumerable: false,
6990
7013
  configurable: true