anentrypoint-design 0.0.327 → 0.0.328

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": "anentrypoint-design",
3
- "version": "0.0.327",
3
+ "version": "0.0.328",
4
4
  "description": "247420 design system SDK — webjsx + modified ripple-ui, single-file ESM bundle for reproducible use of the AnEntrypoint design.",
5
5
  "type": "module",
6
6
  "main": "./dist/247420.js",
package/src/router.js CHANGED
@@ -72,6 +72,42 @@ export class Router {
72
72
  this.render();
73
73
  }
74
74
 
75
+ // Swipe-to-navigate: touch-only (matchMedia (pointer:coarse), same real
76
+ // gate thebird's theme.css already uses for tap-target sizing, per its
77
+ // documented viewport contract). Left swipe -> next registered route,
78
+ // right swipe -> previous, cycling through registration order. A single
79
+ // touch gesture, not a drag-scroll hijack: only fires past a real
80
+ // distance+velocity threshold, and only when the touch didn't move
81
+ // vertically more than horizontally (so a vertical scroll never
82
+ // misfires as a swipe-nav).
83
+ enableSwipeNav({ minDistance = 60, maxVerticalDrift = 50 } = {}) {
84
+ if (typeof window === 'undefined' || !window.matchMedia) return this;
85
+ if (!window.matchMedia('(pointer:coarse)').matches) return this;
86
+ let startX = null, startY = null, startTime = 0;
87
+ const root = document.getElementById('app');
88
+ if (!root) return this;
89
+ root.addEventListener('touchstart', (e) => {
90
+ const t = e.touches[0];
91
+ startX = t.clientX; startY = t.clientY; startTime = Date.now();
92
+ }, { passive: true });
93
+ root.addEventListener('touchend', (e) => {
94
+ if (startX === null) return;
95
+ const t = e.changedTouches[0];
96
+ const dx = t.clientX - startX;
97
+ const dy = Math.abs(t.clientY - startY);
98
+ const dt = Date.now() - startTime;
99
+ startX = null;
100
+ if (dy > maxVerticalDrift || Math.abs(dx) < minDistance || dt > 600) return;
101
+ const names = [...this.routes.keys()];
102
+ const idx = names.indexOf(this.currentRoute);
103
+ if (idx === -1) return;
104
+ const nextIdx = dx < 0 ? idx + 1 : idx - 1;
105
+ if (nextIdx < 0 || nextIdx >= names.length) return;
106
+ this.navigate(names[nextIdx]);
107
+ }, { passive: true });
108
+ return this;
109
+ }
110
+
75
111
  start() {
76
112
  window.addEventListener('popstate', () => this.handlePopState());
77
113
  window.addEventListener('hashchange', () => this.handlePopState());