# iPad swipe between pages: `ga-swipe.js`

**Status:** this is a design preview. It isn't merged, deployed or live. MT asked for a site-wide iPad swipe, with the nav bar following the finger, on 12 Nov 2026.

On an iPad or other touch tablet, one finger swipes sideways between the top-level pages, in **nav-bar order**. The page follows the finger. The active nav knob (the indicator, not a restyle of the pill) tracks the same progress, then settles on the new tab — or snaps back if the swipe is cancelled.

## Page order

The script reads the visible tabs in `#wmC .wcpill` (left to right) and uses their `href`s. That is the same order the live shell already uses.

**On iPad / desktop (`wm-shell-merge.js`, `WMWIDE`, every page has its own slot):**

1. Aerodromes (`main.html`, including `site/ad/*.html` detail pages)
2. Weather (`app.html?tab=map`)
3. ATOs (`app.html?tab=ato`)
4. DFEs (`app.html?tab=dfe`)
5. Pilot (`pilot.html`)
6. Chart (`app.html?tab=chart`)
7. Library (`library.html`)
8. Logbook (`logbook.html`)
9. Brief (`brief.html`)
10. Calculator (`calculator.html`)
11. Status (`status_demo.html`)

**On the phone-sized shell (`wm-shell.js`, five tabs plus a context slot):** Aerodromes, Chart, Weather, ATOs, DFEs, and the current 6th page (Pilot, Calculator, Library, …) when it is showing. The module still follows whatever tabs are actually visible, so the two shells do not need different scripts.

In-page sub-views stay on their parent tab. An aerodrome detail (FACT and the rest) is still Aerodromes: a swipe goes to Weather (or rubber-bands on the left), it does not step through aerodromes. The same for an ATO or DFE detail.

The marketing landing, sign-in / sign-up, privacy and admin/ops pages have no app nav. The script stays quiet there unless a `ga-swipe` meta tag is added. That is a decision for MT if those pages should join the gesture.

## How it behaves

- **The page follows your finger.** The `[data-swipe-target]` (usually `<main>`) moves with `translate3d` only. A small frosted label at the edge names the destination.
- **The nav knob tracks the finger.** Only the existing CSS variables move (`--x`, `--ms`, `--rx`, `--ss`, tab `--wctx`, label opacity, dock width). The pill's look is unchanged. Progress is finger-travel / page-width. On commit it eases to the new tab with `cubic-bezier(.32,.72,0,1)`. On cancel it eases back.
- **It rubber-bands** where no page exists in that direction (Aerodromes to the left, Status to the right on the iPad order). The nav stays on the current tab.
- **A swipe commits** past 28 % of the width, or a flick faster than 0.45 px/ms over more than 40 px. Otherwise it springs back.
- **It stays clear of Safari's own back-swipe.** A touch that starts in the first 24 px from the left edge is left to Safari.
- **It locks to one axis.** The first 10 px decide. If the movement is vertical, the browser scrolls as normal and the swipe lets go.
- **It does nothing inside** inputs, textareas, selects, contenteditable, tables, maps (`[data-map]`, Leaflet, Mapbox, Google maps, canvas), sliders, carousels, sideways scrollers (chips, filter tabs), the nav pill itself, open sheets, text selections, `[data-swipe-ignore]` or `[data-no-swipe]`.
- **With reduced motion on,** nothing tracks or slides. A completed swipe just changes the page.
- **It only runs** on a coarse pointer at 700 px or wider (iPad, tablets). iPhone sizes never get the gesture, same as the first preview. For testing, add `?swipe=1`.
- **It respects the motion budget.** Only transform and opacity animate. `will-change` is set only while dragging. All four themes follow `html[data-theme][data-pal]` (Pearl `day/white`, Champagne `day/beige`, Midnight `night/black`, Amethyst `night/purple`). Portrait and landscape both work; the nav relayouts on resize.
- **Shared math** lives on `GASwipe.math` (`EASE`, `EDGE`, `LOCK`, `COMMIT`, `FLICK`, `rubber`, `shouldCommit`, `axisLock`, `eligible`) so the Mac two-finger trackpad work on `fix/mac-verdict-swipe-12nov` can reuse the same feel without a second set of numbers.

A page can still set an explicit neighbour with a meta tag or `GASwipe.init({...})`. Those values win, which is how the Pilot ⇄ ATO account mocks in this PR keep working (they have no `#wmC`).

## Where to include it (Go Around)

Add one deferred script after the shell, on every app page. No meta tag is needed when `#wmC` is present. Put `data-swipe-target` on `<main>` (keep `#wmC` a sibling on `body`, so the bar does not slide with the page). Mark sideways regions `data-no-swipe`.

| Page | File | Notes |
|---|---|---|
| Aerodromes list | `site/index.html`, `site/main.html` | `<script defer src="ga-swipe.js"></script>` after `wm-shell.js` / `wm-shell-merge.js`. Mark the filter strip `data-no-swipe` if it scrolls sideways. |
| Aerodrome detail | `site/ad/*.html` | Same script. Stay on the Aerodromes tab. Add `data-no-swipe` (or `data-map`) to the map, diagram, filter and any chip scroller. Use the existing `../` prefix already on the nav hrefs. |
| Weather | `site/app.html?tab=map` | Mark the map `data-no-swipe`. |
| ATOs list / ATO detail | `site/app.html?tab=ato` and any ATO detail URL | Details stay on the ATOs tab. Mark carousels and horizontal row filters. |
| DFEs list / DFE detail | `site/app.html?tab=dfe` and any DFE detail URL | Same pattern as ATOs. |
| Pilot (Your page) | `site/pilot.html` | Neighbours are DFEs and Chart on the iPad order. |
| Chart | `site/app.html?tab=chart` | Mark the chart canvas / map `data-no-swipe`. |
| Library | `site/library.html` | |
| Logbook | `site/logbook.html` | |
| Brief | `site/brief.html` | |
| Calculator | `site/calculator.html` | Mark sliders and any horizontal scroller `data-no-swipe`. |
| Status | `site/status.html`, `site/status_demo.html` | Last slot on iPad; rubber-bands to the right. |
| Marketing landing, sign-in / sign-up, privacy, ops / admin | `site/index` landing if separate, auth pages, `privacy.html`, `ops.html`, `dashboard.html` | No app nav. Do not add the script unless MT wants those pages in the gesture. |

Do not touch `gate.ts`, `appdata/`, auth, `wm-pin.js`, `site/wm-core.js`, `_middleware.js` or engine files. Do not change any pill's visual design — only its position during the swipe. Do not merge or deploy this until MT says yes.

```html
<script defer src="ga-swipe.js"></script>
<main data-swipe-target>…</main>
```

Optional override:

```html
<meta name="ga-swipe" content='{"prev":"back","prevLabel":"Back","next":"/ato/account/","nextLabel":"ATO account"}'>
```

`GASwipe.init({ prev, next, prevLabel, nextLabel, target, keepQuery })` is also supported. `keepQuery: true` carries the current query (theme, `swipe=1`) to the next page. The demo uses it for themes.

## Demo

Open `demo/index.html` from the components server (`http://localhost:8811/ipad-swipe/demo/index.html?t=pearl&swipe=1&p=aerodromes`). Themes: `pearl`, `midnight`, `amethyst`, `champagne`. Pages: `p=aerodromes|weather|atos|dfes|pilot|chart|library|logbook|brief|calculator|status|fact`.

## Demo videos

- `/workspace/pilot-ato-pages/out/ipad-swipe-sitewide-landscape-pearl.mp4`
- `/workspace/pilot-ato-pages/out/ipad-swipe-sitewide-portrait-midnight.mp4`
- `/workspace/pilot-ato-pages/out/ipad-swipe-sitewide-grid.png` (still grid)

Each video shows: a cancelled swipe that tracks and snaps back, a run through Aerodromes (including the FACT detail) → Weather → ATOs, then Calculator → Status, a rubber-band at the end, and a swipe back. The nav knob follows throughout.

The earlier Pilot ⇄ ATO clips remain in `demo/ipad-swipe-landscape-1180x820-pearl.mp4` and `demo/ipad-swipe-portrait-820x1180-midnight.mp4`.

## NEXT SESSION — from Designer

- **Go Around:** include `ga-swipe.js` on the app pages in the table above, add `data-swipe-target` to `<main>`, and mark maps, sliders, diagrams, filters and chip rows `data-no-swipe`. No backend. Wait for MT's yes before merging or deploying. Rebase onto live after the scroll/polish release if that lands first.
- Check it on a real iPad in Safari. The demo videos were recorded in headless Chromium with emulated touch, so timings there are only approximate.
- The Mac two-finger trackpad swipe (other branch) should call `GASwipe.math` so both gestures share thresholds, rubber-band and easing. Do not fork a second feel.
- Landing / auth pages are out of the nav order until MT says otherwise.

— Designer
