@weasel-js/routing 1.5.1 → 1.6.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.
@@ -226,6 +226,8 @@ function claimGestureOf(e) {
226
226
  return "longPress";
227
227
  case "wheel":
228
228
  return "wheel";
229
+ case "pinch":
230
+ return "pinch";
229
231
  default:
230
232
  return null;
231
233
  }
@@ -488,11 +490,10 @@ function worldPointOf(event) {
488
490
  switch (event.kind) {
489
491
  case "pointerdown":
490
492
  case "longpress":
491
- return event.x !== void 0 && event.y !== void 0 ? { x: event.x, y: event.y } : void 0;
492
493
  case "click":
493
494
  case "doubleclick":
494
495
  case "contextmenu":
495
- return event.worldX !== void 0 && event.worldY !== void 0 ? { x: event.worldX, y: event.worldY } : void 0;
496
+ return event.x !== void 0 && event.y !== void 0 ? { x: event.x, y: event.y } : void 0;
496
497
  default:
497
498
  return void 0;
498
499
  }
@@ -548,9 +549,11 @@ function createDispatcher(opts) {
548
549
  base.key = { key: event.key, repeat: false };
549
550
  } else if (event.kind === "wheel") {
550
551
  base.wheel = { deltaX: event.deltaX, deltaY: event.deltaY, deltaZ: 0 };
551
- } else if (event.kind === "pointerdown" || event.kind === "click") {
552
- const sx = event.kind === "pointerdown" ? event.x ?? 0 : event.worldX ?? event.pressX ?? 0;
553
- const sy = event.kind === "pointerdown" ? event.y ?? 0 : event.worldY ?? event.pressY ?? 0;
552
+ } else if (event.kind === "pinch") {
553
+ base.pinch = { scale: event.scale, rotation: event.rotation };
554
+ } else if (event.kind === "pointerdown" || event.kind === "click" || event.kind === "doubleclick" || event.kind === "contextmenu") {
555
+ const sx = event.x ?? (event.kind === "click" ? event.pressX : void 0) ?? 0;
556
+ const sy = event.y ?? (event.kind === "click" ? event.pressY : void 0) ?? 0;
554
557
  base.world = { x: sx, y: sy };
555
558
  const affordance = event.kind === "pointerdown" ? event.affordance : void 0;
556
559
  base.drag = {
@@ -566,7 +569,8 @@ function createDispatcher(opts) {
566
569
  const origin = gestureId ? dragOrigins.get(gestureId) : void 0;
567
570
  const ox = origin?.x ?? cx;
568
571
  const oy = origin?.y ?? cy;
569
- const points = gestureId ? dragPoints.get(gestureId) : void 0;
572
+ const live = gestureId ? dragPoints.get(gestureId) : void 0;
573
+ const points = live && event.kind === "pointerup" ? [...live] : live;
570
574
  const eventClientX = event.clientX;
571
575
  const eventClientY = event.clientY;
572
576
  const hasClient = eventClientX !== void 0 && eventClientY !== void 0 && origin?.clientX !== void 0 && origin?.clientY !== void 0;
@@ -789,10 +793,19 @@ function createDispatcher(opts) {
789
793
  affordance: event.affordance,
790
794
  ...resolved
791
795
  };
796
+ } else if (event.kind === "pinch") {
797
+ params = {
798
+ scale: event.scale,
799
+ rotation: event.rotation,
800
+ clientX: event.clientX,
801
+ clientY: event.clientY,
802
+ affordance: event.affordance,
803
+ ...resolved
804
+ };
792
805
  } else if (event.kind === "click" || event.kind === "doubleclick") {
793
806
  params = {
794
- worldX: event.worldX,
795
- worldY: event.worldY,
807
+ worldX: event.x,
808
+ worldY: event.y,
796
809
  affordance: event.affordance,
797
810
  // Press point as well as release point — an action that places
798
811
  // geometry at the click wants the former. See `ClickEvent`.
@@ -802,8 +815,8 @@ function createDispatcher(opts) {
802
815
  };
803
816
  } else if (event.kind === "contextmenu" || event.kind === "longpress") {
804
817
  params = {
805
- worldX: event.kind === "contextmenu" ? event.worldX : event.x,
806
- worldY: event.kind === "contextmenu" ? event.worldY : event.y,
818
+ worldX: event.x,
819
+ worldY: event.y,
807
820
  affordance: event.affordance,
808
821
  bodyTarget: event.bodyTarget,
809
822
  mods: modifiersOf(event),
@@ -1179,6 +1192,7 @@ var SPEC_KIND_TO_GESTURE = {
1179
1192
  key: "keyDown",
1180
1193
  "key-held": "keyHeld",
1181
1194
  wheel: "wheel",
1195
+ pinch: "pinch",
1182
1196
  click: "click",
1183
1197
  doubleClick: "dblTap",
1184
1198
  contextMenu: "contextMenu",
@@ -1510,5 +1524,5 @@ function dlog(namespace, ...args) {
1510
1524
  }
1511
1525
 
1512
1526
  export { ALWAYS, COARSE_TARGET_SCALE, DEFAULT_ALLOWED_CAPABILITIES, DEFAULT_DEVICE_PROFILE, INGEST_STRING_MIMES, NEVER, PREDICATE_TARGET, TOOL_OFFHAND_ID, actionBindings, buildDepsFromRequires, buildRouteRegistry, buildRuleCtx, buildToolOffhandBindings, clientToCanvas, clientToCanvasRect, createDispatcher, describeRule, dlog, evaluate, filterEligible, findConflicts, isDev, isEditableTarget, itemsFromClipboardData, itemsFromDataTransfer, itemsFromFiles, liveScope, makeToolOffhandAction, matchBest, matchSorted, matchesKeyBinding, offhandKeyFor, openPointerSession, pointerGestureId, recordModeSwitch, reportRouteConflicts, resolveDeviceProfile, resolveParams, routeGestureForSpecKind, routesForSpec, scopeBindings, specificity, targetConsultsAffordance, validateActionDefaultBinding, validateActionId };
1513
- //# sourceMappingURL=chunk-ZZICE4J7.js.map
1514
- //# sourceMappingURL=chunk-ZZICE4J7.js.map
1527
+ //# sourceMappingURL=chunk-D2TZLDP5.js.map
1528
+ //# sourceMappingURL=chunk-D2TZLDP5.js.map