@rive-app/canvas-lite 2.19.3 → 2.19.5

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.19.3",
3
+ "version": "2.19.5",
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.js CHANGED
@@ -582,7 +582,9 @@ h.onRuntimeInitialized = function() {
582
582
  return C[z];
583
583
  }, set(C, z, E) {
584
584
  if (z in B) {
585
- return B[z] = E, !0;
585
+ return w.u.push(() => {
586
+ B[z] = E;
587
+ }), !0;
586
588
  }
587
589
  },});
588
590
  };
@@ -2259,7 +2261,7 @@ Pc();
2259
2261
  /* 2 */
2260
2262
  /***/ ((module) => {
2261
2263
 
2262
- module.exports = JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.19.3","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}}');
2264
+ module.exports = JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.19.5","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}}');
2263
2265
 
2264
2266
  /***/ }),
2265
2267
  /* 3 */
@@ -2469,7 +2471,40 @@ var registerTouchInteractions = function (_a) {
2469
2471
  typeof window === "undefined") {
2470
2472
  return null;
2471
2473
  }
2474
+ /**
2475
+ * After a touchend event, some browsers may fire synthetic mouse events
2476
+ * (mouseover, mousedown, mousemove, mouseup) if the touch interaction did not cause
2477
+ * any default action (such as scrolling).
2478
+ *
2479
+ * This is done to simulate the behavior of a mouse for applications that do not support
2480
+ * touch events.
2481
+ *
2482
+ * We're keeping track of the previous event to not send the synthetic mouse events if the
2483
+ * touch event was a click (touchstart -> touchend).
2484
+ *
2485
+ * This is only needed when `isTouchScrollEnabled` is false
2486
+ * When true, `preventDefault()` is called which prevents this behaviour.
2487
+ **/
2488
+ var _prevEventType = null;
2489
+ var _syntheticEventsActive = false;
2472
2490
  var processEventCallback = function (event) {
2491
+ // Exit early out of all synthetic mouse events
2492
+ // https://stackoverflow.com/questions/9656990/how-to-prevent-simulated-mouse-events-in-mobile-browsers
2493
+ // https://stackoverflow.com/questions/25572070/javascript-touchend-versus-click-dilemma
2494
+ if (_syntheticEventsActive && event instanceof MouseEvent) {
2495
+ // Synthetic event finished
2496
+ if (event.type == "mouseup") {
2497
+ _syntheticEventsActive = false;
2498
+ }
2499
+ return;
2500
+ }
2501
+ // Test if it's a "touch click". This could cause the browser to send
2502
+ // synthetic mouse events.
2503
+ _syntheticEventsActive =
2504
+ isTouchScrollEnabled &&
2505
+ event.type === "touchend" &&
2506
+ _prevEventType === "touchstart";
2507
+ _prevEventType = event.type;
2473
2508
  var boundingRect = event.currentTarget.getBoundingClientRect();
2474
2509
  var _a = getClientCoordinates(event, isTouchScrollEnabled), clientX = _a.clientX, clientY = _a.clientY;
2475
2510
  if (!clientX && !clientY) {
@@ -2549,8 +2584,12 @@ var registerTouchInteractions = function (_a) {
2549
2584
  canvas.addEventListener("mousemove", callback);
2550
2585
  canvas.addEventListener("mousedown", callback);
2551
2586
  canvas.addEventListener("mouseup", callback);
2552
- canvas.addEventListener("touchmove", callback);
2553
- canvas.addEventListener("touchstart", callback);
2587
+ canvas.addEventListener("touchmove", callback, {
2588
+ passive: isTouchScrollEnabled,
2589
+ });
2590
+ canvas.addEventListener("touchstart", callback, {
2591
+ passive: isTouchScrollEnabled,
2592
+ });
2554
2593
  canvas.addEventListener("touchend", callback);
2555
2594
  return function () {
2556
2595
  canvas.removeEventListener("mouseover", callback);