@astryxdesign/core 0.7.6 → 0.7.7-canary.0d1ddcd
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/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +23 -3
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +16 -9
- package/dist/Chat/ChatComposerInput.d.ts +9 -0
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +2 -0
- package/dist/Chat/ChatMessage.js +2 -2
- package/dist/Chat/chatMessage.vars.stylex.d.ts +8 -8
- package/dist/Chat/chatMessage.vars.stylex.js +8 -8
- package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteInput.js +8 -1
- package/dist/DateInput/MonthScroller.d.ts.map +1 -1
- package/dist/DateInput/MonthScroller.js +72 -2
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +6 -0
- package/dist/DropdownMenu/useMenuOverflow.d.ts +13 -3
- package/dist/DropdownMenu/useMenuOverflow.d.ts.map +1 -1
- package/dist/DropdownMenu/useMenuOverflow.js +31 -8
- package/dist/Field/PanelSearchInput.d.ts.map +1 -1
- package/dist/Field/PanelSearchInput.js +8 -1
- package/dist/Field/textEntryTraits.d.ts +6 -6
- package/dist/Field/textEntryTraits.js +6 -6
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +1 -0
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +25 -13
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +404 -131
- package/dist/Slider/sliderTouchController.d.ts +189 -0
- package/dist/Slider/sliderTouchController.d.ts.map +1 -0
- package/dist/Slider/sliderTouchController.js +1017 -0
- package/dist/Slider/useSliderTouch.d.ts +22 -0
- package/dist/Slider/useSliderTouch.d.ts.map +1 -0
- package/dist/Slider/useSliderTouch.js +56 -0
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +19 -9
- package/dist/astryx.css +33 -6
- package/dist/gestures/GestureArena.d.ts.map +1 -1
- package/dist/gestures/GestureArena.js +4 -1
- package/dist/gestures/GestureHost.d.ts +72 -2
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +643 -5
- package/dist/gestures/GestureRecognizer.d.ts +15 -1
- package/dist/gestures/GestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/GestureRecognizer.js +12 -0
- package/dist/gestures/PanGestureRecognizer.d.ts +8 -0
- package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PinchGestureRecognizer.d.ts +5 -1
- package/dist/gestures/PinchGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PinchGestureRecognizer.js +10 -0
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +3 -3
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/ScreenEdgePanGestureRecognizer.js +7 -5
- package/dist/gestures/nativeScroll.d.ts +16 -2
- package/dist/gestures/nativeScroll.d.ts.map +1 -1
- package/dist/gestures/nativeScroll.js +39 -8
- package/dist/gestures/recognizerInternals.d.ts +4 -2
- package/dist/gestures/recognizerInternals.d.ts.map +1 -1
- package/dist/gestures/types.d.ts +11 -0
- package/dist/gestures/types.d.ts.map +1 -1
- package/dist/gestures/types.js +7 -0
- package/dist/gestures/wheelSegmenter.d.ts +45 -0
- package/dist/gestures/wheelSegmenter.d.ts.map +1 -0
- package/dist/gestures/wheelSegmenter.js +98 -0
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +140 -19
- package/dist/motion/paging.d.ts +58 -0
- package/dist/motion/paging.d.ts.map +1 -0
- package/dist/motion/paging.js +128 -0
- package/dist/motion/uikit/index.d.ts +2 -1
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +2 -1
- package/dist/motion/uikit/paging.d.ts +160 -0
- package/dist/motion/uikit/paging.d.ts.map +1 -0
- package/dist/motion/uikit/paging.js +162 -0
- package/dist/motion/uikit/scroll.d.ts +0 -19
- package/dist/motion/uikit/scroll.d.ts.map +1 -1
- package/dist/motion/uikit/scroll.js +2 -21
- package/dist/motion/uikit/slider.d.ts +97 -0
- package/dist/motion/uikit/slider.d.ts.map +1 -0
- package/dist/motion/uikit/slider.js +111 -0
- package/dist/motion/uikit/springs.d.ts +46 -1
- package/dist/motion/uikit/springs.d.ts.map +1 -1
- package/dist/motion/uikit/springs.js +48 -4
- package/package.json +5 -5
- package/src/AppShell/AppShell.doc.mjs +10 -0
- package/src/AppShell/AppShell.tsx +48 -2
- package/src/BottomSheet/BottomSheetPanel.tsx +16 -9
- package/src/Chat/Chat.doc.mjs +1 -0
- package/src/Chat/ChatComposerInput.doc.mjs +11 -0
- package/src/Chat/ChatComposerInput.tsx +11 -0
- package/src/Chat/ChatMessage.tsx +2 -2
- package/src/Chat/chatMessage.vars.stylex.ts +8 -8
- package/src/CommandPalette/CommandPaletteInput.tsx +6 -0
- package/src/DateInput/MonthScroller.tsx +63 -5
- package/src/Drawer/Drawer.tsx +6 -0
- package/src/DropdownMenu/useMenuOverflow.ts +44 -8
- package/src/Field/PanelSearchInput.tsx +6 -0
- package/src/Field/textEntryTraits.ts +6 -6
- package/src/Link/Link.tsx +3 -0
- package/src/Selector/Selector.tsx +29 -2
- package/src/Slider/Slider.doc.mjs +11 -7
- package/src/Slider/Slider.tsx +539 -132
- package/src/Slider/sliderTouchController.ts +1209 -0
- package/src/Slider/useSliderTouch.ts +78 -0
- package/src/Typeahead/BaseTypeahead.tsx +16 -8
- package/src/gestures/GestureArena.ts +1 -0
- package/src/gestures/GestureHost.ts +765 -5
- package/src/gestures/GestureRecognizer.ts +28 -0
- package/src/gestures/PanGestureRecognizer.ts +8 -0
- package/src/gestures/PinchGestureRecognizer.ts +16 -1
- package/src/gestures/README.md +63 -0
- package/src/gestures/ScreenEdgePanGestureRecognizer.ts +7 -5
- package/src/gestures/nativeScroll.ts +49 -9
- package/src/gestures/recognizerInternals.ts +9 -2
- package/src/gestures/types.ts +12 -0
- package/src/gestures/wheelSegmenter.ts +114 -0
- package/src/motion/MEASUREMENTS.md +8 -1
- package/src/motion/README.md +3 -2
- package/src/motion/animator.ts +193 -25
- package/src/motion/paging.ts +138 -0
- package/src/motion/uikit/index.ts +2 -1
- package/src/motion/uikit/paging.ts +162 -0
- package/src/motion/uikit/scroll.ts +2 -18
- package/src/motion/uikit/slider.ts +105 -0
- package/src/motion/uikit/springs.ts +37 -2
- package/dist/motion/selectPage.d.ts +0 -26
- package/dist/motion/selectPage.d.ts.map +0 -1
- package/dist/motion/selectPage.js +0 -55
- package/src/motion/selectPage.ts +0 -55
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file slider.ts
|
|
5
|
+
* @input Nothing: data only
|
|
6
|
+
* @output Exports `slider`: UISlider's hit target, tracking rule, release
|
|
7
|
+
* coast, lift, drop and end haptic, measured on the iOS 26.2 simulator
|
|
8
|
+
* @position The slider domain of the UIKit constants table (motion/uikit).
|
|
9
|
+
* Lengths are in pt (CSS px). Tests check each leaf's `@source`.
|
|
10
|
+
*
|
|
11
|
+
* SYNC: When modified, update:
|
|
12
|
+
* - /packages/core/src/Slider/sliderTouchController.ts
|
|
13
|
+
* - /packages/core/src/Slider/Slider.tsx
|
|
14
|
+
* - /packages/core/src/motion/uikit/slider.test.ts
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {SLIDER_RELEASE_SPRING} from './springs';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* UISlider's touch values: hit target, tracking, release coast, lift, drop
|
|
21
|
+
* and the end-of-track haptic.
|
|
22
|
+
*/
|
|
23
|
+
export const slider = {
|
|
24
|
+
/**
|
|
25
|
+
* The thumb's touch target, a square in pt centered on the thumb. It is
|
|
26
|
+
* the 37 × 24 pt thumb grown by its hit edge insets: 12 pt above and
|
|
27
|
+
* below, 5.5 pt left and right. UIKit hit-tests inside the control's frame
|
|
28
|
+
* first, so the lab's 40 pt frame clipped it to 48 × 40.
|
|
29
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro.
|
|
30
|
+
* `_thumbHitEdgeInsets` reads {−12, −5.5, −12, −5.5}. Touch-downs on a
|
|
31
|
+
* 4 pt grid take the thumb from −24 to +20 pt in x. A track tap away
|
|
32
|
+
* from the thumb moves nothing. Oct 23 2026
|
|
33
|
+
*/
|
|
34
|
+
thumbHitTarget: 48,
|
|
35
|
+
/**
|
|
36
|
+
* Value range per track length of finger travel. The value moves by
|
|
37
|
+
* (max − min) × translation ÷ the track's full length. The translation
|
|
38
|
+
* counts from the pan's threshold: the touch-down point plus 10 pt along
|
|
39
|
+
* the track. 1 means one full range per track length.
|
|
40
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. In
|
|
41
|
+
* drags at 120 to 2000 pt/s, each event's value is v0 plus the
|
|
42
|
+
* translation past 10 pt ÷ 300. Past the max end, the value leaves 1
|
|
43
|
+
* only once the finger comes back past where it reached 1. Oct 23 2026
|
|
44
|
+
*/
|
|
45
|
+
trackingGain: 1,
|
|
46
|
+
/**
|
|
47
|
+
* The coast after the lift. The thumb and the value spring from where the
|
|
48
|
+
* finger left them to the projected target, with the release velocity.
|
|
49
|
+
* Critically damped, it never overshoots a target ahead of it.
|
|
50
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. The
|
|
51
|
+
* `UIViewSpringAnimationBehavior` at the lift reads response 0.4 and
|
|
52
|
+
* damping ratio 1. Four releases fit it per frame, at rms 0.11 pt or
|
|
53
|
+
* less. Oct 23 2026
|
|
54
|
+
*/
|
|
55
|
+
releaseSpring: SLIDER_RELEASE_SPRING,
|
|
56
|
+
/**
|
|
57
|
+
* The deceleration rate of the coast's momentum projection, per ms
|
|
58
|
+
* (WWDC18's `project`). It is not UIScrollView's normal rate (0.998), so
|
|
59
|
+
* pass it to the projection explicitly.
|
|
60
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. The
|
|
61
|
+
* release behavior's projection deceleration reads 0.996. Oct 23 2026
|
|
62
|
+
*/
|
|
63
|
+
releaseProjectionRate: 0.996,
|
|
64
|
+
/**
|
|
65
|
+
* How much of the projection the coast travels. The target is the lift
|
|
66
|
+
* value plus this share of the projected distance. A finger lifted outside
|
|
67
|
+
* the control's tracking bounds coasts back to the lift value instead.
|
|
68
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. The
|
|
69
|
+
* release behavior's target smoothing reads 0.4. A 126.9 pt/s release
|
|
70
|
+
* travels 12.56 pt, against 12.64 predicted. Oct 23 2026
|
|
71
|
+
*/
|
|
72
|
+
releaseProjectionShare: 0.4,
|
|
73
|
+
/**
|
|
74
|
+
* The thumb's growth under a finger, uniform about its center (37 × 24 to
|
|
75
|
+
* 57.35 × 37.2 pt).
|
|
76
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. The lens
|
|
77
|
+
* frame settled during an 800 ms hold. Oct 23 2026
|
|
78
|
+
*/
|
|
79
|
+
liftScale: 1.55,
|
|
80
|
+
/**
|
|
81
|
+
* The lift: the thumb grows to `liftScale` when the finger lands.
|
|
82
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. The lens
|
|
83
|
+
* width per frame in an 800 ms hold fits one spring at rms 0.31 pt.
|
|
84
|
+
* Oct 23 2026
|
|
85
|
+
*/
|
|
86
|
+
liftSpring: {response: 0.215, dampingRatio: 0.6},
|
|
87
|
+
/**
|
|
88
|
+
* The drop: the thumb shrinks back to its rest size when the finger lifts,
|
|
89
|
+
* while the coast runs.
|
|
90
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. The
|
|
91
|
+
* lens's spring at the lift of an 800 ms hold reads response 0.5 s and
|
|
92
|
+
* damping ratio 0.7. The width per frame fits it at rms 0.10 pt.
|
|
93
|
+
* Oct 23 2026
|
|
94
|
+
*/
|
|
95
|
+
dropSpring: {response: 0.5, dampingRatio: 0.7},
|
|
96
|
+
/**
|
|
97
|
+
* The feedback each time the value reaches an end, once per entry. It
|
|
98
|
+
* re-arms when the value leaves the end, in the drag and the coast. UIKit
|
|
99
|
+
* plays "Micro Tap Medium", and the web stand-in is the closest kind.
|
|
100
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. The
|
|
101
|
+
* haptics log of drags into both ends shows the fluid slider generator's
|
|
102
|
+
* "Micro Tap Medium" once per entry. Oct 23 2026
|
|
103
|
+
*/
|
|
104
|
+
endHaptic: 'impactMedium',
|
|
105
|
+
} as const;
|
|
@@ -454,6 +454,33 @@ export const KEYBOARD_SPRING = {
|
|
|
454
454
|
*/
|
|
455
455
|
export const BANNER_SPRING = {mass: 3, stiffness: 1000, damping: 500} as const;
|
|
456
456
|
|
|
457
|
+
/**
|
|
458
|
+
* UISlider's release: after a finger lifts, the thumb settles on this spring
|
|
459
|
+
* toward 0.4 of the release's momentum projection. It is critically damped,
|
|
460
|
+
* so it never overshoots a target ahead of it.
|
|
461
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. The
|
|
462
|
+
* `UIViewSpringAnimationBehavior` at the lift reads response 0.4 and
|
|
463
|
+
* damping ratio 1. Four releases fit it per frame (the UIKit slider
|
|
464
|
+
* table). Oct 23 2026
|
|
465
|
+
*/
|
|
466
|
+
export const SLIDER_RELEASE_SPRING = {response: 0.4, dampingRatio: 1} as const;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* UISlider's lift: a finger's touch-down scales the thumb up on this spring.
|
|
470
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. The
|
|
471
|
+
* thumb's scale per frame after touch-down (the UIKit slider table).
|
|
472
|
+
* Oct 23 2026
|
|
473
|
+
*/
|
|
474
|
+
export const SLIDER_LIFT_SPRING = {response: 0.215, dampingRatio: 0.6} as const;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* UISlider's drop: the lift's end scales the thumb back down on this spring.
|
|
478
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, iPhone 17 Pro. The
|
|
479
|
+
* thumb's scale per frame after the lift (the UIKit slider table).
|
|
480
|
+
* Oct 23 2026
|
|
481
|
+
*/
|
|
482
|
+
export const SLIDER_DROP_SPRING = {response: 0.5, dampingRatio: 0.7} as const;
|
|
483
|
+
|
|
457
484
|
/**
|
|
458
485
|
* Every spring above, by row name: the table the existing readers use. A
|
|
459
486
|
* component imports only the rows it plays (`architecture:component-style-authoring`
|
|
@@ -494,10 +521,15 @@ export const springs = {
|
|
|
494
521
|
segmentedThumb: SEGMENTED_THUMB_SPRING,
|
|
495
522
|
keyboard: KEYBOARD_SPRING,
|
|
496
523
|
banner: BANNER_SPRING,
|
|
524
|
+
sliderRelease: SLIDER_RELEASE_SPRING,
|
|
525
|
+
sliderLift: SLIDER_LIFT_SPRING,
|
|
526
|
+
sliderDrop: SLIDER_DROP_SPRING,
|
|
497
527
|
} as const;
|
|
498
528
|
|
|
499
529
|
/**
|
|
500
|
-
* The
|
|
530
|
+
* The only springs that are motion roles. The touch presentations' record
|
|
531
|
+
* names some, and a component's own record names others, such as Slider's
|
|
532
|
+
* three. The generated motion role table lists each with its record.
|
|
501
533
|
* The registry takes these rows alone, so registering ships no other spring.
|
|
502
534
|
*/
|
|
503
535
|
const SPRING_ROLES = {
|
|
@@ -516,10 +548,13 @@ const SPRING_ROLES = {
|
|
|
516
548
|
contextMenuLift: CONTEXT_MENU_LIFT_SPRING,
|
|
517
549
|
contextMenuDismiss: CONTEXT_MENU_DISMISS_SPRING,
|
|
518
550
|
contextMenuMorph: CONTEXT_MENU_MORPH_SPRING,
|
|
551
|
+
sliderRelease: SLIDER_RELEASE_SPRING,
|
|
552
|
+
sliderLift: SLIDER_LIFT_SPRING,
|
|
553
|
+
sliderDrop: SLIDER_DROP_SPRING,
|
|
519
554
|
};
|
|
520
555
|
|
|
521
556
|
/**
|
|
522
|
-
* Registers the springs
|
|
557
|
+
* Registers the role springs (`SPRING_ROLES`) as internal motion roles
|
|
523
558
|
* (motion/roles.ts), by their row names (`springs.settle`). Every other
|
|
524
559
|
* spring, UIKit's menu spring under Reduce Motion and the keyboard's
|
|
525
560
|
* included, is not a role. Nothing registers on import: the touch code that
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file selectPage.ts
|
|
3
|
-
* @input A release (position, velocity), the page size and count, the
|
|
4
|
-
* current page
|
|
5
|
-
* @output Exports `selectPage`: the page a paging release settles on
|
|
6
|
-
* @position UIScrollView paging (`isPagingEnabled`) on the release policy
|
|
7
|
-
* (resolveSnapPoint.ts). Pure: no DOM, no React
|
|
8
|
-
*
|
|
9
|
-
* SYNC: When modified, update selectPage.test.ts.
|
|
10
|
-
*/
|
|
11
|
-
import type { SnapSelection } from './projection.js';
|
|
12
|
-
/**
|
|
13
|
-
* UIScrollView paging (`isPagingEnabled`): the page a release settles on, at
|
|
14
|
-
* most one page from `currentPage`, chosen by projecting the release with
|
|
15
|
-
* the paging projection rate (uikit/scroll.ts; a GUESS until measured).
|
|
16
|
-
* Pages are `pageSize` apart starting at 0.
|
|
17
|
-
*/
|
|
18
|
-
export declare function selectPage({ position, velocity, pageSize, pageCount, currentPage, rate, }: {
|
|
19
|
-
position: number;
|
|
20
|
-
velocity: number;
|
|
21
|
-
pageSize: number;
|
|
22
|
-
pageCount: number;
|
|
23
|
-
currentPage: number;
|
|
24
|
-
rate?: number;
|
|
25
|
-
}): SnapSelection;
|
|
26
|
-
//# sourceMappingURL=selectPage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selectPage.d.ts","sourceRoot":"","sources":["../../src/motion/selectPage.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAIhD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,WAAW,EACX,IAAmC,GACpC,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,aAAa,CAiBhB"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file selectPage.ts
|
|
5
|
-
* @input A release (position, velocity), the page size and count, the
|
|
6
|
-
* current page
|
|
7
|
-
* @output Exports `selectPage`: the page a paging release settles on
|
|
8
|
-
* @position UIScrollView paging (`isPagingEnabled`) on the release policy
|
|
9
|
-
* (resolveSnapPoint.ts). Pure: no DOM, no React
|
|
10
|
-
*
|
|
11
|
-
* SYNC: When modified, update selectPage.test.ts.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { resolveSnapPoint } from "./resolveSnapPoint.js";
|
|
15
|
-
import { scroll } from "./uikit/scroll.js";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* UIScrollView paging (`isPagingEnabled`): the page a release settles on, at
|
|
19
|
-
* most one page from `currentPage`, chosen by projecting the release with
|
|
20
|
-
* the paging projection rate (uikit/scroll.ts; a GUESS until measured).
|
|
21
|
-
* Pages are `pageSize` apart starting at 0.
|
|
22
|
-
*/
|
|
23
|
-
export function selectPage({
|
|
24
|
-
position,
|
|
25
|
-
velocity,
|
|
26
|
-
pageSize,
|
|
27
|
-
pageCount,
|
|
28
|
-
currentPage,
|
|
29
|
-
rate = scroll.paging.projectionRate
|
|
30
|
-
}) {
|
|
31
|
-
const points = Array.from({
|
|
32
|
-
length: Math.max(1, pageCount)
|
|
33
|
-
}, (_, i) => i * pageSize);
|
|
34
|
-
// The release policy (resolveSnapPoint.ts), with the paging rate as the
|
|
35
|
-
// seconds of velocity it projects, no flick and one page per release.
|
|
36
|
-
const {
|
|
37
|
-
index,
|
|
38
|
-
projected
|
|
39
|
-
} = resolveSnapPoint({
|
|
40
|
-
points,
|
|
41
|
-
position,
|
|
42
|
-
velocity,
|
|
43
|
-
flickThreshold: Infinity,
|
|
44
|
-
projection: {
|
|
45
|
-
seconds: rate / (1 - rate) / 1000
|
|
46
|
-
},
|
|
47
|
-
fromIndex: currentPage,
|
|
48
|
-
maxSteps: 1
|
|
49
|
-
});
|
|
50
|
-
return {
|
|
51
|
-
index,
|
|
52
|
-
value: points[index],
|
|
53
|
-
projected
|
|
54
|
-
};
|
|
55
|
-
}
|
package/src/motion/selectPage.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file selectPage.ts
|
|
5
|
-
* @input A release (position, velocity), the page size and count, the
|
|
6
|
-
* current page
|
|
7
|
-
* @output Exports `selectPage`: the page a paging release settles on
|
|
8
|
-
* @position UIScrollView paging (`isPagingEnabled`) on the release policy
|
|
9
|
-
* (resolveSnapPoint.ts). Pure: no DOM, no React
|
|
10
|
-
*
|
|
11
|
-
* SYNC: When modified, update selectPage.test.ts.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import type {SnapSelection} from './projection';
|
|
15
|
-
import {resolveSnapPoint} from './resolveSnapPoint';
|
|
16
|
-
import {scroll} from './uikit/scroll';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* UIScrollView paging (`isPagingEnabled`): the page a release settles on, at
|
|
20
|
-
* most one page from `currentPage`, chosen by projecting the release with
|
|
21
|
-
* the paging projection rate (uikit/scroll.ts; a GUESS until measured).
|
|
22
|
-
* Pages are `pageSize` apart starting at 0.
|
|
23
|
-
*/
|
|
24
|
-
export function selectPage({
|
|
25
|
-
position,
|
|
26
|
-
velocity,
|
|
27
|
-
pageSize,
|
|
28
|
-
pageCount,
|
|
29
|
-
currentPage,
|
|
30
|
-
rate = scroll.paging.projectionRate,
|
|
31
|
-
}: {
|
|
32
|
-
position: number;
|
|
33
|
-
velocity: number;
|
|
34
|
-
pageSize: number;
|
|
35
|
-
pageCount: number;
|
|
36
|
-
currentPage: number;
|
|
37
|
-
rate?: number;
|
|
38
|
-
}): SnapSelection {
|
|
39
|
-
const points = Array.from(
|
|
40
|
-
{length: Math.max(1, pageCount)},
|
|
41
|
-
(_, i) => i * pageSize,
|
|
42
|
-
);
|
|
43
|
-
// The release policy (resolveSnapPoint.ts), with the paging rate as the
|
|
44
|
-
// seconds of velocity it projects, no flick and one page per release.
|
|
45
|
-
const {index, projected} = resolveSnapPoint({
|
|
46
|
-
points,
|
|
47
|
-
position,
|
|
48
|
-
velocity,
|
|
49
|
-
flickThreshold: Infinity,
|
|
50
|
-
projection: {seconds: rate / (1 - rate) / 1000},
|
|
51
|
-
fromIndex: currentPage,
|
|
52
|
-
maxSteps: 1,
|
|
53
|
-
});
|
|
54
|
-
return {index, value: points[index], projected};
|
|
55
|
-
}
|