Skip to content

chore(core): a pager that pages like a UIKit paging scroll view - #8146

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c23-pager
Nov 3, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c23-pager

Conversation

@vjeux

@vjeux vjeux commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent: an internal behavior module (the pager hook) for Carousel; no public API.

User need

Paging should feel like iOS: pages follow the finger, the lift picks UIKit's page, the settle survives a busy main thread; a mouse or trackpad pages it too.

Evidence

Simulator and emulator clips (iOS 26.2; P12: Android 15); Cindy checked the preview (#9364) on a phone and a trackpad, covering the two Mobile Safari behaviors the pager relies on (P7). Red ring: the finger.

Path Clip
P1 slow drag past half: next page
P2 slow drag before half: back
P3 short flick: one page
P4 rubber band past page 0
P5 goTo(3); mid-drag
P6 still finger stops a settle; a drag catches
P7 600 ms block after the lift
P8 RTL: right goes forward
P9 scrolling page: vertical, 35° and 50°
P10 children pages (Carousel cards)
P12 Android: slow drag; flick

Problem and solution fit

  • The pan moves the track 1:1, rubber-banding past the ends.
  • At the lift, pageForRelease applies chore(core): UIKit's paging values and math, measured on iOS 26.2 #8145's thresholds; a release moving back toward its start page stays there (FR37). The track settles on UIKit's integrator, on the compositor.
  • A still finger stops a settle after 85 ms; a drag catches it.
  • goTo runs setContentOffset(_:animated:): it cancels a drag, keeps a running move's velocity (FR6), and reads its duration and curve through resolveMotion (FR4; no role names them).
  • pages: 'children': each child is a page at its start edge.
  • Axis: a drag is the pager's when |dx| ≥ |dy|, claimed at its pan's 10 pt start.
  • Every pointer (FR19, FR43): a mouse drags like a finger; the pan follows a trackpad's scroll, never a mouse wheel's, at most a page per swipe.
  • Callbacks a setOptions or controlled goTo causes run next frame (INV2); a replaced viewport or track ends a drag on its start page.

Current specification

spec:AST-094 FR3–FR6, FR8–FR10, FR14, FR19, FR24, FR36–FR41, FR43, DEC-24, DEC-25; design:reduced-motion DR2, DR3; architecture:react-component-runtime INV2, INV3, INV13.

With the spec owners' text, FR6, DEC-25 and the FR6 pager row narrow #8145's gap: only a page change during a drag starts from rest. It needs a spec owner's /approve-spec <head sha>.

Public delta and caller burden

No behavior change: useAttachment's users keep their lifecycle, and nothing renders the pager until #8153. The changeset is [chore].

Design and alternatives

  • The owner renders pages; the pager writes translate.
  • A release reports its page two frames into its settle.

Supersedes #8692: its trackpad swipe rules are in this commit.

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

  • New in this head, each failing before its fix:
    • "a resize after a forward wrap keeps the wrapped page: no jump and no callback" (before: virtual page 4);
    • "a backward trackpad swipe during a goTo across pages follows the fingers and lands from where it began" (before: frozen, then page 3);
    • "a trackpad swipe during a mouse release's settle starts from the page on screen: it moves at most one page from there" (before: 652 px);
    • "a loop's smaller count keeps the page shown where it can" and the same after a forward wrap (before: index 1);
    • "a release whose report still waits when a looping pager's count changes is reported first" (before: no report);
    • "turning loop off while a swipe's report waits reports that page first" (before: no report);
    • "a loop's smaller count drops a waiting report whose page is gone, and clamps unreported" (before: a report for page 4);
    • "turning loop off with a smaller count keeps the page shown by the old count" (before: page 1), and "turning loop on with a smaller count clamps the page shown" (before: page 1);
    • "a loop's smaller count at rest on a wrapped page settles nothing", "turning loop off on a wrapped page names no virtual page in onSettle" and "a loop's smaller count that clamps the page settles from the page shown" (before: settle:0:2, settle:2:7 and settle:2:1);
    • "a resize while a finger holds a caught settle leaves the track under the finger, and the lift settles once" (before: the track moved under the finger);
    • "a writing-direction flip re-places the track at the next measure" (before: a 1,200 px jump).
  • The page rule, failing on a nearest-page rule: "a stale start page past either end counts from the nearest real page, so a release still pages" and "a release whose velocity points back toward the start page cancels, whatever the travel".
  • Kept from earlier heads, each red first: the trackpad catch during a goTo with no jump and the late backward spike; the viewport replaced mid-drag or before its report; a touch with the pan off; nearestPage before the first measure; the pan's neutral name; the viewport's own frames; INV2's deferred callbacks; FR6's retarget velocity (jsdom and both browsers); children pages, CSS zoom included; the 10 pt claim at 35° and 45°; FR41's selection lock; the controlled index; FR19 and FR43's every-pointer and trackpad cases (Chromium skips the trackpad ones: its CDP wheels lack a trackpad's wheelDelta); FR4's resolveMotion read; useAttachmentPair's lifecycle (hooks/useAttachment.ts).
  • Red first for FR43's swipe rules: c7f6c48 (the 1,000 px scroll reached −882.9 px, past the next page at −400; the 42 px spike paged; the swipe during a settle landed one page on).
  • Under load, every hold and storyboard proof holds its motion at its first frame (armHold, armed before the input), and every release storyboard judges each frame against UIKit's curve for the lift velocity the pan read, within 1.5 px. Waits count from the input: a motion must start within 5 s of the input's end, and the retarget proof waits in its own task 100 ms into its 300 ms curve. A failed case's message starts with a load report.
  • P11 Reduce Motion (tests): nothing travels after the lift; releases and coarse-pointer goTo cross-fade (200 ms); fine non-touch releases land at once (FR43). Limit: in a block an unpainted page stays blank (sheet); owners layer nearby pages.
  • Recorded on the iOS 26.2 simulator (Mobile Safari) and the Android 15 emulator (Chrome 124): the clips above; earlier sheets and per-frame data.
  • Local gates at 879fa48: check:knowledge, check:changesets, check:motion-roles, check:use-client, sync:exports:check and Prettier pass; strict eslint on the changed files has no warnings; core tsc 0; jsdom hooks, motion, gestures and Carousel 2,230 passed (usePager.test.ts 123); the WebKit job's routing test (ci-interaction-webkit.test.mjs) 14 passed; the usePager browser proofs: Chromium on a pinned pair of 2 cores, 4 workers: 23 passed, 2 skipped; WebKit, the CI job's profile (podman --cpus=4, CI=1, LP_NUM_THREADS=4, 1 worker) ×10: 220 passed, 30 skipped. At c21b226d8b: check:i18n-runtime and check:i18n-catalog, lint:strict 0 errors, the full pnpm test:ui (first run 18,378 passed, 1 failed, 27 skipped; second 18,376 passed, 1 failed, 29 skipped; the reds are main's lazy-import waits, whose cause fix is test: module loads are awaited, not raced against test clocks #9447) and WebKit --cpus=3 at 1 and 16 workers, 22 passed and 3 skipped each
  • No .github files: git diff --stat eadd175390a18ba5c5ba7735e8a29e9c38ae6202...HEAD -- .github is empty against main at eadd175. The WebKit interaction job's pager scope landed as ci: the WebKit interaction lane runs the pager's proof for the pager files #9377.
  • Size: over the 2,000-line threshold (12 files, 6,173 lines added, 50 removed) as one spec unit: the pager with its every-pointer attach, the trackpad following and FR43's swipe rules, which FR43 asks of this head together. Tests and fixtures are 4,580 of the lines (jsdom 3,051, 106, 38 and 2; browser 1,364; bundle 19); the hook (imported once per adopter: useCarouselPaging.ts) is 1,446; the rest is the paging math's FR6 carry, the table's constants and registration, useAttachment's pair (+56 −14), the record's FR6 narrowing (+6 −8) and the changeset
  • Records checked: spec:AST-094 FR4, FR6, FR19, FR37, FR41, FR43 and DEC-24; spec:AST-100 FR2; spec:AST-107 DEC-2 (a factory under the hook); design:reduced-motion DR2, DR3; architecture:react-component-runtime INV2, INV3, INV13; architecture:knowledge-contracts INV29; and the global records pnpm specs:for --diff lists. No public API change. The owner-gated path is docs/specs/AST-094-touch-presentations/spec.md; pnpm check:knowledge passes.

Writing rubric results

Run over the record text this PR changes in spec:AST-094 (the spec owners' wording, pasted as given):

  • R1 narration: none. FR6 and DEC-25 state that a page change during a drag starts from rest.
  • R2 research: none in the record.
  • R3 evidence: the FR6 pager row names states, not changes.
  • R4 rejected alternatives: DEC-25's one Rejected: line is unchanged.
  • R5 change references: none.
  • R6 open questions: none added.

Stack: this PR, then #8153 (#8145, #8676 and #8360 have merged), one commit here, no merges.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants