@rive-app/webgl 2.19.3 → 2.19.4

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.19.3",
3
+ "version": "2.19.4",
4
4
  "description": "Rive's webgl based web api.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.js CHANGED
@@ -4053,7 +4053,7 @@ Ie();
4053
4053
  /* 2 */
4054
4054
  /***/ ((module) => {
4055
4055
 
4056
- module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"2.19.3","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}}');
4056
+ module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"2.19.4","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}}');
4057
4057
 
4058
4058
  /***/ }),
4059
4059
  /* 3 */
@@ -4263,7 +4263,40 @@ var registerTouchInteractions = function (_a) {
4263
4263
  typeof window === "undefined") {
4264
4264
  return null;
4265
4265
  }
4266
+ /**
4267
+ * After a touchend event, some browsers may fire synthetic mouse events
4268
+ * (mouseover, mousedown, mousemove, mouseup) if the touch interaction did not cause
4269
+ * any default action (such as scrolling).
4270
+ *
4271
+ * This is done to simulate the behavior of a mouse for applications that do not support
4272
+ * touch events.
4273
+ *
4274
+ * We're keeping track of the previous event to not send the synthetic mouse events if the
4275
+ * touch event was a click (touchstart -> touchend).
4276
+ *
4277
+ * This is only needed when `isTouchScrollEnabled` is false
4278
+ * When true, `preventDefault()` is called which prevents this behaviour.
4279
+ **/
4280
+ var _prevEventType = null;
4281
+ var _syntheticEventsActive = false;
4266
4282
  var processEventCallback = function (event) {
4283
+ // Exit early out of all synthetic mouse events
4284
+ // https://stackoverflow.com/questions/9656990/how-to-prevent-simulated-mouse-events-in-mobile-browsers
4285
+ // https://stackoverflow.com/questions/25572070/javascript-touchend-versus-click-dilemma
4286
+ if (_syntheticEventsActive && event instanceof MouseEvent) {
4287
+ // Synthetic event finished
4288
+ if (event.type == "mouseup") {
4289
+ _syntheticEventsActive = false;
4290
+ }
4291
+ return;
4292
+ }
4293
+ // Test if it's a "touch click". This could cause the browser to send
4294
+ // synthetic mouse events.
4295
+ _syntheticEventsActive =
4296
+ isTouchScrollEnabled &&
4297
+ event.type === "touchend" &&
4298
+ _prevEventType === "touchstart";
4299
+ _prevEventType = event.type;
4267
4300
  var boundingRect = event.currentTarget.getBoundingClientRect();
4268
4301
  var _a = getClientCoordinates(event, isTouchScrollEnabled), clientX = _a.clientX, clientY = _a.clientY;
4269
4302
  if (!clientX && !clientY) {
@@ -4343,8 +4376,12 @@ var registerTouchInteractions = function (_a) {
4343
4376
  canvas.addEventListener("mousemove", callback);
4344
4377
  canvas.addEventListener("mousedown", callback);
4345
4378
  canvas.addEventListener("mouseup", callback);
4346
- canvas.addEventListener("touchmove", callback);
4347
- canvas.addEventListener("touchstart", callback);
4379
+ canvas.addEventListener("touchmove", callback, {
4380
+ passive: isTouchScrollEnabled,
4381
+ });
4382
+ canvas.addEventListener("touchstart", callback, {
4383
+ passive: isTouchScrollEnabled,
4384
+ });
4348
4385
  canvas.addEventListener("touchend", callback);
4349
4386
  return function () {
4350
4387
  canvas.removeEventListener("mouseover", callback);