@rive-app/canvas 2.13.0 → 2.14.0
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 +1 -1
- package/rive.d.ts +21 -1
- package/rive.js +39 -14
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export type { FileAsset, FontAsset, ImageAsset } from './rive_advanced.mjs';
|
|
|
5
5
|
*/
|
|
6
6
|
export type VoidCallback = () => void;
|
|
7
7
|
export type AssetLoadCallback = (asset: rc.FileAsset, bytes: Uint8Array) => Boolean;
|
|
8
|
+
interface SetupRiveListenersOptions {
|
|
9
|
+
isTouchScrollEnabled?: boolean;
|
|
10
|
+
}
|
|
8
11
|
/**
|
|
9
12
|
* Type for artboard bounds
|
|
10
13
|
*/
|
|
@@ -202,6 +205,12 @@ export interface RiveParameters {
|
|
|
202
205
|
* will be attached to the <canvas> element
|
|
203
206
|
*/
|
|
204
207
|
shouldDisableRiveListeners?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* For Rive Listeners, allows scrolling behavior to still occur on canvas elements
|
|
210
|
+
* when a touch/drag action is performed on touch-enabled devices. Otherwise,
|
|
211
|
+
* scroll behavior may be prevented on touch/drag actions on the canvas by default.
|
|
212
|
+
*/
|
|
213
|
+
isTouchScrollEnabled?: boolean;
|
|
205
214
|
/**
|
|
206
215
|
* Enable Rive Events to be handled by the runtime. This means any special Rive Event may have
|
|
207
216
|
* a side effect that takes place implicitly.
|
|
@@ -298,10 +307,21 @@ export declare class Rive {
|
|
|
298
307
|
durations: number[];
|
|
299
308
|
frameTimes: number[];
|
|
300
309
|
frameCount: number;
|
|
310
|
+
isTouchScrollEnabled: boolean;
|
|
301
311
|
constructor(params: RiveParameters);
|
|
302
312
|
static new(params: RiveParameters): Rive;
|
|
303
313
|
private init;
|
|
304
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Setup Rive Listeners on the canvas
|
|
316
|
+
* @param riveListenerOptions - Enables TouchEvent events on the canvas. Set to true to allow
|
|
317
|
+
* touch scrolling on the canvas element on touch-enabled devices
|
|
318
|
+
* i.e. { isTouchScrollEnabled: true }
|
|
319
|
+
*/
|
|
320
|
+
setupRiveListeners(riveListenerOptions?: SetupRiveListenersOptions): void;
|
|
321
|
+
/**
|
|
322
|
+
* Remove Rive Listeners setup on the canvas
|
|
323
|
+
*/
|
|
324
|
+
removeRiveListeners(): void;
|
|
305
325
|
private initData;
|
|
306
326
|
private initArtboard;
|
|
307
327
|
drawFrame(): void;
|
package/rive.js
CHANGED
|
@@ -731,7 +731,7 @@ function Ya(a, b) {
|
|
|
731
731
|
return Xa(c, a, b);
|
|
732
732
|
}));
|
|
733
733
|
}
|
|
734
|
-
var N, P, bb = {
|
|
734
|
+
var N, P, bb = {433284:(a, b, c, d, e) => {
|
|
735
735
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
736
736
|
return 0;
|
|
737
737
|
}
|
|
@@ -794,9 +794,9 @@ var N, P, bb = {236660:(a, b, c, d, e) => {
|
|
|
794
794
|
}
|
|
795
795
|
window.h.Aa += 1;
|
|
796
796
|
return 1;
|
|
797
|
-
},
|
|
797
|
+
}, 435462:() => {
|
|
798
798
|
"undefined" !== typeof window.h && (--window.h.Aa, 0 === window.h.Aa && delete window.h);
|
|
799
|
-
},
|
|
799
|
+
}, 435626:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 435730:() => {
|
|
800
800
|
try {
|
|
801
801
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
802
802
|
a.close();
|
|
@@ -804,7 +804,7 @@ var N, P, bb = {236660:(a, b, c, d, e) => {
|
|
|
804
804
|
} catch (c) {
|
|
805
805
|
return 0;
|
|
806
806
|
}
|
|
807
|
-
},
|
|
807
|
+
}, 435901:(a, b, c, d, e, f) => {
|
|
808
808
|
if ("undefined" === typeof window.h) {
|
|
809
809
|
return -1;
|
|
810
810
|
}
|
|
@@ -850,7 +850,7 @@ var N, P, bb = {236660:(a, b, c, d, e) => {
|
|
|
850
850
|
a == window.h.H.za && g.$.connect(g.I.destination);
|
|
851
851
|
g.qb = f;
|
|
852
852
|
return window.h.Gc(g);
|
|
853
|
-
},
|
|
853
|
+
}, 438778:a => window.h.sa(a).I.sampleRate, 438851:a => {
|
|
854
854
|
a = window.h.sa(a);
|
|
855
855
|
void 0 !== a.$ && (a.$.onaudioprocess = function() {
|
|
856
856
|
}, a.$.disconnect(), a.$ = void 0);
|
|
@@ -858,13 +858,13 @@ var N, P, bb = {236660:(a, b, c, d, e) => {
|
|
|
858
858
|
a.I.close();
|
|
859
859
|
a.I = void 0;
|
|
860
860
|
a.qb = void 0;
|
|
861
|
-
},
|
|
861
|
+
}, 439251:a => {
|
|
862
862
|
window.h.Db(a);
|
|
863
|
-
},
|
|
863
|
+
}, 439301:a => {
|
|
864
864
|
a = window.h.sa(a);
|
|
865
865
|
a.I.resume();
|
|
866
866
|
a.state = window.h.ga.yb;
|
|
867
|
-
},
|
|
867
|
+
}, 439440:a => {
|
|
868
868
|
a = window.h.sa(a);
|
|
869
869
|
a.I.suspend();
|
|
870
870
|
a.state = window.h.ga.stopped;
|
|
@@ -3404,7 +3404,7 @@ Zd();
|
|
|
3404
3404
|
/* 2 */
|
|
3405
3405
|
/***/ ((module) => {
|
|
3406
3406
|
|
|
3407
|
-
module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.
|
|
3407
|
+
module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.14.0","description":"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.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
3408
3408
|
|
|
3409
3409
|
/***/ }),
|
|
3410
3410
|
/* 3 */
|
|
@@ -3438,11 +3438,15 @@ var _this = undefined;
|
|
|
3438
3438
|
* @param event - Either a TouchEvent or a MouseEvent
|
|
3439
3439
|
* @returns - Coordinates of the clientX and clientY properties from the touch/mouse event
|
|
3440
3440
|
*/
|
|
3441
|
-
var getClientCoordinates = function (event) {
|
|
3441
|
+
var getClientCoordinates = function (event, isTouchScrollEnabled) {
|
|
3442
3442
|
var _a, _b;
|
|
3443
3443
|
if (["touchstart", "touchmove"].indexOf(event.type) > -1 &&
|
|
3444
3444
|
((_a = event.touches) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
3445
|
-
|
|
3445
|
+
// This flag, if false, prevents touch events on the canvas default behavior
|
|
3446
|
+
// which may prevent scrolling if a drag motion on the canvas is performed
|
|
3447
|
+
if (!isTouchScrollEnabled) {
|
|
3448
|
+
event.preventDefault();
|
|
3449
|
+
}
|
|
3446
3450
|
return {
|
|
3447
3451
|
clientX: event.touches[0].clientX,
|
|
3448
3452
|
clientY: event.touches[0].clientY,
|
|
@@ -3467,7 +3471,7 @@ var getClientCoordinates = function (event) {
|
|
|
3467
3471
|
* the state machine pointer move/up/down functions based on cursor interaction
|
|
3468
3472
|
*/
|
|
3469
3473
|
var registerTouchInteractions = function (_a) {
|
|
3470
|
-
var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment;
|
|
3474
|
+
var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment, _c = _a.isTouchScrollEnabled, isTouchScrollEnabled = _c === void 0 ? false : _c;
|
|
3471
3475
|
if (!canvas ||
|
|
3472
3476
|
!stateMachines.length ||
|
|
3473
3477
|
!renderer ||
|
|
@@ -3478,7 +3482,7 @@ var registerTouchInteractions = function (_a) {
|
|
|
3478
3482
|
}
|
|
3479
3483
|
var processEventCallback = function (event) {
|
|
3480
3484
|
var boundingRect = event.currentTarget.getBoundingClientRect();
|
|
3481
|
-
var _a = getClientCoordinates(event), clientX = _a.clientX, clientY = _a.clientY;
|
|
3485
|
+
var _a = getClientCoordinates(event, isTouchScrollEnabled), clientX = _a.clientX, clientY = _a.clientY;
|
|
3482
3486
|
if (!clientX && !clientY) {
|
|
3483
3487
|
return;
|
|
3484
3488
|
}
|
|
@@ -4664,6 +4668,7 @@ var Rive = /** @class */ (function () {
|
|
|
4664
4668
|
this.durations = [];
|
|
4665
4669
|
this.frameTimes = [];
|
|
4666
4670
|
this.frameCount = 0;
|
|
4671
|
+
this.isTouchScrollEnabled = false;
|
|
4667
4672
|
/**
|
|
4668
4673
|
* Used be draw to track when a second of active rendering time has passed.
|
|
4669
4674
|
* Used for debugging purposes
|
|
@@ -4674,6 +4679,7 @@ var Rive = /** @class */ (function () {
|
|
|
4674
4679
|
this.buffer = params.buffer;
|
|
4675
4680
|
this.layout = (_a = params.layout) !== null && _a !== void 0 ? _a : new Layout();
|
|
4676
4681
|
this.shouldDisableRiveListeners = !!params.shouldDisableRiveListeners;
|
|
4682
|
+
this.isTouchScrollEnabled = !!params.isTouchScrollEnabled;
|
|
4677
4683
|
this.automaticallyHandleEvents = !!params.automaticallyHandleEvents;
|
|
4678
4684
|
this.enableRiveAssetCDN =
|
|
4679
4685
|
params.enableRiveAssetCDN === undefined
|
|
@@ -4775,12 +4781,22 @@ var Rive = /** @class */ (function () {
|
|
|
4775
4781
|
console.error(e);
|
|
4776
4782
|
});
|
|
4777
4783
|
};
|
|
4778
|
-
|
|
4784
|
+
/**
|
|
4785
|
+
* Setup Rive Listeners on the canvas
|
|
4786
|
+
* @param riveListenerOptions - Enables TouchEvent events on the canvas. Set to true to allow
|
|
4787
|
+
* touch scrolling on the canvas element on touch-enabled devices
|
|
4788
|
+
* i.e. { isTouchScrollEnabled: true }
|
|
4789
|
+
*/
|
|
4790
|
+
Rive.prototype.setupRiveListeners = function (riveListenerOptions) {
|
|
4779
4791
|
var _this = this;
|
|
4780
4792
|
if (!this.shouldDisableRiveListeners) {
|
|
4781
4793
|
var activeStateMachines = (this.animator.stateMachines || [])
|
|
4782
4794
|
.filter(function (sm) { return sm.playing && _this.runtime.hasListeners(sm.instance); })
|
|
4783
4795
|
.map(function (sm) { return sm.instance; });
|
|
4796
|
+
var touchScrollEnabledOption = this.isTouchScrollEnabled;
|
|
4797
|
+
if (riveListenerOptions && 'isTouchScrollEnabled' in riveListenerOptions) {
|
|
4798
|
+
touchScrollEnabledOption = riveListenerOptions.isTouchScrollEnabled;
|
|
4799
|
+
}
|
|
4784
4800
|
this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
|
|
4785
4801
|
canvas: this.canvas,
|
|
4786
4802
|
artboard: this.artboard,
|
|
@@ -4789,9 +4805,18 @@ var Rive = /** @class */ (function () {
|
|
|
4789
4805
|
rive: this.runtime,
|
|
4790
4806
|
fit: this._layout.runtimeFit(this.runtime),
|
|
4791
4807
|
alignment: this._layout.runtimeAlignment(this.runtime),
|
|
4808
|
+
isTouchScrollEnabled: touchScrollEnabledOption,
|
|
4792
4809
|
});
|
|
4793
4810
|
}
|
|
4794
4811
|
};
|
|
4812
|
+
/**
|
|
4813
|
+
* Remove Rive Listeners setup on the canvas
|
|
4814
|
+
*/
|
|
4815
|
+
Rive.prototype.removeRiveListeners = function () {
|
|
4816
|
+
if (this.eventCleanup) {
|
|
4817
|
+
this.eventCleanup();
|
|
4818
|
+
}
|
|
4819
|
+
};
|
|
4795
4820
|
// Initializes runtime with Rive data and preps for playing
|
|
4796
4821
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay) {
|
|
4797
4822
|
var _a;
|