|
4 | 4 | * @file pageControl.ts |
5 | 5 | * @input Nothing; data only |
6 | 6 | * @output Exports `pageControl`: UIPageControl's measured geometry, its |
7 | | - * default indicator alphas and its tap rule |
| 7 | + * default indicator alphas, its tap and scrub rules, its window of |
| 8 | + * indicators, its fades and its jog past the window's edge |
8 | 9 | * @position The page-control domain of the UIKit constants table |
9 | 10 | * (motion/uikit); read by the lab PageControl |
10 | 11 | * |
11 | 12 | * Every value was read from a stock UIPageControl (default style, default |
12 | 13 | * tint) on the iOS 26.2 simulator, iPhone 17 Pro: its frames, |
13 | 14 | * `intrinsicContentSize`, `size(forNumberOfPages:)`, the indicator images' |
14 | | - * rendered pixels, and `valueChanged` under HID touches. Geometry is in |
15 | | - * points. |
| 15 | + * rendered pixels and animations, and `valueChanged` under HID touches, over |
| 16 | + * a mid-grey background. Geometry is in points. |
16 | 17 | * |
17 | 18 | * Every leaf carries one or more `@source`; uikit.test.ts enforces it. |
18 | 19 | * |
19 | 20 | * SYNC: When modified, update: |
20 | 21 | * - /packages/lab/src/PageControl/pageControlModel.ts |
| 22 | + * - /packages/cli/assets/docs/motion.doc.mjs (`pnpm generate:motion-roles`) |
21 | 23 | * - /packages/core/src/motion/README.md (domain list) |
22 | 24 | */ |
23 | 25 |
|
24 | 26 | /** |
25 | 27 | * UIPageControl on iOS 26. |
26 | 28 | * @experimental |
27 | 29 | */ |
| 30 | +import {registerMotionTable} from '../roles'; |
| 31 | + |
28 | 32 | export const pageControl = { |
29 | 33 | /** |
30 | 34 | * Diameter of one page indicator. |
@@ -82,4 +86,137 @@ export const pageControl = { |
82 | 86 | * touch, one page per tap (2026-10-23) |
83 | 87 | */ |
84 | 88 | tapStep: 1, |
| 89 | + /** |
| 90 | + * How far a finger travels from where it landed before the control |
| 91 | + * scrubs: from then on the page is the indicator under the finger. |
| 92 | + * Movement alone starts it; holding first changes nothing. |
| 93 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, HID |
| 94 | + * drags across 5- and 50-page controls from a still touch and after an |
| 95 | + * 800 ms hold: the first page change at 16.3 and 16.7 pt (2026-10-24) |
| 96 | + */ |
| 97 | + scrubStartDistance: 16, |
| 98 | + /** |
| 99 | + * While scrubbing, the page switches at the midpoint between two |
| 100 | + * indicators' centres: one page per indicator pitch (9.67 + 8 pt), the |
| 101 | + * same going back. |
| 102 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, a |
| 103 | + * 5-page control: changes at x 192.3, 210.3, 229.0 against midpoints |
| 104 | + * 192.3, 210.2, 227.8 between indicator centres (2026-10-24) |
| 105 | + */ |
| 106 | + scrubSwitchPoint: 0.5, |
| 107 | + /** |
| 108 | + * A finger held on the control turns it interactive after this many |
| 109 | + * milliseconds, moving or not: the platter shows and the other indicators |
| 110 | + * dim to `interactingOtherIndicatorAlpha`. |
| 111 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, the |
| 112 | + * indicators' contentsMultiplyColor animations start 153–160 ms after |
| 113 | + * touch-down, interactionState 2 (2026-10-24) |
| 114 | + */ |
| 115 | + interactionDelayMs: 155, |
| 116 | + /** |
| 117 | + * Opacity of the indicators other than the current one while a finger is |
| 118 | + * on the control. |
| 119 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, held |
| 120 | + * control: the other indicators' tint alpha 0.25 (2026-10-24) |
| 121 | + */ |
| 122 | + interactingOtherIndicatorAlpha: 0.25, |
| 123 | + /** |
| 124 | + * At most this many indicator slots show. Past it the row is a window |
| 125 | + * that moves only when the current page would land in a shrunk slot. |
| 126 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, a |
| 127 | + * 50-page control at pages 0, 10, 25 and 49: ten slots on the 17.67 pt |
| 128 | + * pitch, centred on the control (2026-10-24) |
| 129 | + */ |
| 130 | + visibleSlots: 10, |
| 131 | + /** |
| 132 | + * Where pages continue past the window, its last two slots on that side |
| 133 | + * shrink to these diameters, outermost last; the slots beyond show |
| 134 | + * nothing. |
| 135 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, a |
| 136 | + * 50-page control: edge indicators 7.33 and 4.31 pt (scale 0.7588 and |
| 137 | + * 0.4461) (2026-10-24) |
| 138 | + */ |
| 139 | + edgeIndicatorSizes: [7.33, 4.31], |
| 140 | + /** |
| 141 | + * When the window moves, every indicator slides to its new slot and |
| 142 | + * takes its new size on this spring. |
| 143 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, a |
| 144 | + * 50-page control at page 10 tapped to 11: UIView spring dampingRatio 1, |
| 145 | + * response 0.15 (tracking), the strip sliding 17.67 pt in about 0.2 s |
| 146 | + * (2026-10-24) |
| 147 | + */ |
| 148 | + windowSlide: {response: 0.15, dampingRatio: 1}, |
| 149 | + /** |
| 150 | + * The window starts to move this many milliseconds after the page changes; |
| 151 | + * the new current indicator lights first, in its shrunk slot. |
| 152 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, a |
| 153 | + * 50-page control at page 10 tapped to 11: the strip starts to slide |
| 154 | + * about 50 ms after valueChanged (2026-10-24) |
| 155 | + */ |
| 156 | + windowSlideDelayMs: 50, |
| 157 | + /** |
| 158 | + * After a tap, the indicator that stops being current fades to the |
| 159 | + * other indicators' opacity over this many milliseconds, on `fadeOutCurve`. |
| 160 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, taps: |
| 161 | + * contentsMultiplyColor CABasicAnimation 0.125 s (2026-10-24) |
| 162 | + */ |
| 163 | + tapFadeOutMs: 125, |
| 164 | + /** |
| 165 | + * After any other page change (scrubbing, or the app setting the page), |
| 166 | + * the indicator that stops being current fades over this many |
| 167 | + * milliseconds. |
| 168 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, |
| 169 | + * programmatic currentPage changes and scrubs: contentsMultiplyColor |
| 170 | + * CABasicAnimation 0.25 s (2026-10-24) |
| 171 | + */ |
| 172 | + fadeOutMs: 250, |
| 173 | + /** |
| 174 | + * The curve of both fades out. |
| 175 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, the |
| 176 | + * fade's timing function control points (0, 0, 0.58, 1) (2026-10-24) |
| 177 | + */ |
| 178 | + fadeOutCurve: [0, 0, 0.58, 1], |
| 179 | + /** |
| 180 | + * Any other opacity change (the new current indicator lighting, the |
| 181 | + * others dimming while a finger is down and recovering at the lift, the |
| 182 | + * platter showing) takes this many milliseconds: a switch. |
| 183 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, |
| 184 | + * contentsMultiplyColor and opacity CABasicAnimations 0.015625 s |
| 185 | + * (2026-10-24) |
| 186 | + */ |
| 187 | + switchMs: 15.625, |
| 188 | + /** |
| 189 | + * The curve of those switches. |
| 190 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, the |
| 191 | + * switch's timing function control points (0.42, 0, 0.58, 1) |
| 192 | + * (2026-10-24) |
| 193 | + */ |
| 194 | + switchCurve: [0.42, 0, 0.58, 1], |
| 195 | + /** |
| 196 | + * Past the window's edge while scrubbing, the control steps pages on its |
| 197 | + * own, faster the further the finger is past the edge of the control's |
| 198 | + * content: this many pages per second per point. |
| 199 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, a |
| 200 | + * 50-page control scrubbed right at 40 pt/s: intervals from 266 ms 19 pt |
| 201 | + * past the content edge to 66 ms at 76 pt, least squares 0.173 pages/s |
| 202 | + * per pt; a run to the left settled at 10 pages/s 77 pt past it |
| 203 | + * (2026-10-24) |
| 204 | + */ |
| 205 | + jogRatePerPoint: 0.173, |
| 206 | + /** |
| 207 | + * The fastest the control steps pages past the window's edge, pages per |
| 208 | + * second. |
| 209 | + * @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro, a |
| 210 | + * 50-page control held 108 pt past the content edge: one page every |
| 211 | + * 61–71 ms (2026-10-24) |
| 212 | + */ |
| 213 | + jogMaxRate: 15, |
85 | 214 | } as const; |
| 215 | + |
| 216 | +// The window's slide (spring and delay) and the fades and switches (durations |
| 217 | +// and curves) are motion roles a theme may retune (motion/roles.ts). When a |
| 218 | +// held finger turns the control interactive decides who holds the touch, not |
| 219 | +// how anything moves. |
| 220 | +registerMotionTable('pageControl', pageControl, { |
| 221 | + exclude: ['interactionDelayMs'], |
| 222 | +}); |
0 commit comments