diff --git a/dist/index.html b/dist/index.html index cb12139..a4470c7 100644 --- a/dist/index.html +++ b/dist/index.html @@ -8270,6 +8270,26 @@ function App($$anchor, $$props) { window.addEventListener("hashchange", onHash); return () => window.removeEventListener("hashchange", onHash); }); + const SWIPE_THRESHOLD = 60; + let touchAnchor = /* @__PURE__ */ state(null); + function onSwipeStart(e) { + if (get(viewMode) === "radar" || !e.touches || !e.touches[0]) return; + set(touchAnchor, { + x: e.touches[0].clientX, + y: e.touches[0].clientY + }, true); + } + function onSwipeEnd(e) { + if (get(viewMode) === "radar" || !get(touchAnchor) || !e.changedTouches || !e.changedTouches[0]) return; + const t = e.changedTouches[0]; + const dx = t.clientX - get(touchAnchor).x; + const dy = t.clientY - get(touchAnchor).y; + set(touchAnchor, null); + if (Math.abs(dx) < SWIPE_THRESHOLD || Math.abs(dx) < Math.abs(dy)) return; + const idx = VALID_VIEWS.indexOf(get(viewMode)); + const next = VALID_VIEWS[Math.min(Math.max(idx + (dx < 0 ? 1 : -1), 0), VALID_VIEWS.length - 1)]; + if (next !== get(viewMode)) setView(next); + } let initDone = /* @__PURE__ */ state(false); let geoError = /* @__PURE__ */ state(""); user_effect(() => { @@ -8509,6 +8529,8 @@ function App($$anchor, $$props) { delegated("click", button_12, () => setView("daily")); delegated("click", button_13, () => setView("detail")); delegated("click", button_14, () => setView("radar")); + delegated("touchstart", div_10, onSwipeStart, void 0, true); + delegated("touchend", div_10, onSwipeEnd); append($$anchor, fragment); }; if_block(node_8, ($$render) => { @@ -8547,7 +8569,11 @@ function App($$anchor, $$props) { append($$anchor, div); pop(); } -delegate(["click"]); +delegate([ + "click", + "touchstart", + "touchend" +]); mount(App, { target: document.getElementById("app") }); //#endregion