@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
package/dist/motion/animator.js
CHANGED
|
@@ -643,7 +643,7 @@ export function createAnimator(element, options = {}) {
|
|
|
643
643
|
if (segment == null) {
|
|
644
644
|
return null;
|
|
645
645
|
}
|
|
646
|
-
if (time >=
|
|
646
|
+
if (time >= endOf(property, segment)) {
|
|
647
647
|
return null;
|
|
648
648
|
}
|
|
649
649
|
return segment;
|
|
@@ -668,26 +668,84 @@ export function createAnimator(element, options = {}) {
|
|
|
668
668
|
};
|
|
669
669
|
|
|
670
670
|
/**
|
|
671
|
-
*
|
|
672
|
-
*
|
|
673
|
-
|
|
674
|
-
|
|
671
|
+
* A held curve's start once a frame dated its call, as the browser's start
|
|
672
|
+
* moves it: by that frame's lead over the call's own time.
|
|
673
|
+
*/
|
|
674
|
+
const datedFromLatest = (segment, latest) => latest == null || segment.group == null ? null : {
|
|
675
|
+
latest,
|
|
676
|
+
start: segment.start + latest - segment.group.provisional
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* When a waiting curve's call had its first frame, which put the curve on
|
|
681
|
+
* screen. Undefined for a curve that does not wait, or whose call has had
|
|
682
|
+
* no first frame.
|
|
683
|
+
*/
|
|
684
|
+
const shownSince = (property, segment) => segment.group?.resolved === false ? segment.group.latest?.get(CHANNEL_OF[property]) : undefined;
|
|
685
|
+
|
|
686
|
+
/** A curve's end, dated from its call's first frame while it waits. */
|
|
687
|
+
const endOf = (property, segment) => (datedFromLatest(segment, shownSince(property, segment))?.start ?? segment.start) + segment.duration;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Takes a curve on screen out of the call that still waits for the
|
|
691
|
+
* browser's start. The curve keeps its course, dated from the call's first
|
|
692
|
+
* frame. A call that has no channel left starts at that frame.
|
|
693
|
+
*/
|
|
694
|
+
const leaveWaitingCall = (segment, channel, latest) => {
|
|
695
|
+
const group = segment.group;
|
|
696
|
+
if (group == null) {
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
const index = group.segments.indexOf(segment);
|
|
700
|
+
if (index >= 0) {
|
|
701
|
+
group.segments.splice(index, 1);
|
|
702
|
+
}
|
|
703
|
+
segment.start += latest - group.provisional;
|
|
704
|
+
segment.group = undefined;
|
|
705
|
+
if (!CHANNELS[channel].some(p => segments.get(p)?.group === group)) {
|
|
706
|
+
group.latest?.delete(channel);
|
|
707
|
+
group.channels.delete(channel);
|
|
708
|
+
}
|
|
709
|
+
if (group.channels.size === 0 && group.segments.length === 0) {
|
|
710
|
+
resolveGroup(group, latest);
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* The value on screen at `time`. Until the browser reports its start, a
|
|
716
|
+
* held curve shows its first value. A frame that ran without that start
|
|
717
|
+
* dates the curve. Without that frame, a later time reads from the
|
|
718
|
+
* provisional start, so a companion that samples ahead follows the curve's
|
|
719
|
+
* shape.
|
|
675
720
|
*/
|
|
676
721
|
const valueAt = (property, time) => {
|
|
677
722
|
const segment = segments.get(property);
|
|
678
|
-
if (segment != null && isHeld(segment)
|
|
723
|
+
if (segment != null && isHeld(segment)) {
|
|
724
|
+
// The compositor starts the call near its first frame. The curve is
|
|
725
|
+
// dated as the browser's start would date it. A curve that joined by an
|
|
726
|
+
// older clock keeps its lead over the call's own time.
|
|
727
|
+
const latest = segment.group?.latest?.get(CHANNEL_OF[property]);
|
|
728
|
+
const dated = datedFromLatest(segment, latest);
|
|
729
|
+
if (dated != null) {
|
|
730
|
+
const elapsed = Math.max(time, dated.latest) - dated.start;
|
|
731
|
+
return elapsed >= segment.duration ? segment.target : segment.at(elapsed);
|
|
732
|
+
}
|
|
679
733
|
// Nothing has moved on screen until the browser starts the call.
|
|
680
|
-
|
|
734
|
+
if (time <= now()) {
|
|
735
|
+
return segment.at(0);
|
|
736
|
+
}
|
|
681
737
|
}
|
|
682
738
|
return curveAt(property, time);
|
|
683
739
|
};
|
|
684
740
|
const velocityAt = (property, time) => {
|
|
685
741
|
const held = segments.get(property);
|
|
686
742
|
if (held != null && isHeld(held)) {
|
|
687
|
-
// Still at its start on screen, but moving in the model
|
|
688
|
-
// carries the velocity the curve has reached by now
|
|
689
|
-
// moves all land before the browser starts any keeps its speed.
|
|
690
|
-
|
|
743
|
+
// Still at its start on screen, but moving in the model. A retarget
|
|
744
|
+
// carries the velocity the curve has reached by now. So a flick whose
|
|
745
|
+
// moves all land before the browser starts any keeps its speed. Past
|
|
746
|
+
// its first frame, it reads from that frame, as its value does.
|
|
747
|
+
const dated = datedFromLatest(held, held.group?.latest?.get(CHANNEL_OF[property]));
|
|
748
|
+
return held.speed(Math.max(0, dated != null && time > dated.latest ? time - dated.start : time - held.start));
|
|
691
749
|
}
|
|
692
750
|
const segment = segmentAt(property, time);
|
|
693
751
|
if (segment == null || time < segment.start) {
|
|
@@ -854,12 +912,49 @@ export function createAnimator(element, options = {}) {
|
|
|
854
912
|
// Settled curves become resting values.
|
|
855
913
|
for (const property of properties) {
|
|
856
914
|
const segment = segments.get(property);
|
|
857
|
-
if (segment != null && time >=
|
|
915
|
+
if (segment != null && time >= endOf(property, segment)) {
|
|
858
916
|
resting[property] = segment.target;
|
|
859
917
|
segments.delete(property);
|
|
860
918
|
}
|
|
861
919
|
}
|
|
862
920
|
const moving = properties.filter(p => segments.has(p));
|
|
921
|
+
if (callGroup == null) {
|
|
922
|
+
// A call that starts now rebuilds a channel the compositor has moving
|
|
923
|
+
// since a first frame without a known start. The channel carries on
|
|
924
|
+
// from that frame, with a start of its own, instead of starting its
|
|
925
|
+
// curve again.
|
|
926
|
+
for (const property of moving) {
|
|
927
|
+
const segment = segments.get(property);
|
|
928
|
+
const latest = shownSince(property, segment);
|
|
929
|
+
if (latest != null) {
|
|
930
|
+
leaveWaitingCall(segment, channel, latest);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
// An explicit call can rebuild a channel while one of its curves still
|
|
935
|
+
// waits for the browser's start. The animation then joins the current
|
|
936
|
+
// call, or else that waiting call, with no start of its own.
|
|
937
|
+
const waiting = callGroup ?? moving.map(p => segments.get(p).group).find(group => group != null && !group.resolved) ?? null;
|
|
938
|
+
const rebuiltAfterFirstFrame = waiting?.framed === true;
|
|
939
|
+
// The new animation starts at the frame that commits it, from its first
|
|
940
|
+
// keyframe. That holds for a waiting call it joins after that call's
|
|
941
|
+
// first frame, and for every waiting call it takes a curve from. So this
|
|
942
|
+
// channel's reads below, and until that frame, take that first value.
|
|
943
|
+
const restarted = new Set();
|
|
944
|
+
if (rebuiltAfterFirstFrame) {
|
|
945
|
+
restarted.add(waiting);
|
|
946
|
+
}
|
|
947
|
+
if (callGroup != null) {
|
|
948
|
+
for (const property of moving) {
|
|
949
|
+
const group = segments.get(property).group;
|
|
950
|
+
if (group != null && group !== callGroup && !group.resolved) {
|
|
951
|
+
restarted.add(group);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
for (const group of restarted) {
|
|
956
|
+
group.latest?.delete(channel);
|
|
957
|
+
}
|
|
863
958
|
if (channel === 'translate') {
|
|
864
959
|
// The animation built below starts from the value at `time` (its first
|
|
865
960
|
// keyframe); a rebase or a retarget builds a new one, so a new start.
|
|
@@ -887,10 +982,6 @@ export function createAnimator(element, options = {}) {
|
|
|
887
982
|
previous?.cancel();
|
|
888
983
|
return;
|
|
889
984
|
}
|
|
890
|
-
// A channel rebuilt by an explicit call (set, rebase, a retarget of
|
|
891
|
-
// another axis) while one of its curves still waits for the browser's
|
|
892
|
-
// start keeps that start: no explicit start for this animation.
|
|
893
|
-
const waiting = callGroup ?? moving.map(p => segments.get(p).group).find(group => group != null && !group.resolved) ?? null;
|
|
894
985
|
// The keyframes start where the animation will: at the waiting call's
|
|
895
986
|
// own time, which its start moves to the browser's (resolveGroup), so a
|
|
896
987
|
// write later in the task keeps the screen on the model's clock.
|
|
@@ -996,6 +1087,15 @@ export function createAnimator(element, options = {}) {
|
|
|
996
1087
|
waiting.channels.add(channel);
|
|
997
1088
|
// A cancel before the first frame rejects its ready promise.
|
|
998
1089
|
animation.ready?.catch(() => {});
|
|
1090
|
+
if (rebuiltAfterFirstFrame) {
|
|
1091
|
+
// The frame that commits it dates this channel's start again. The
|
|
1092
|
+
// call's other channels keep their own.
|
|
1093
|
+
requestFrame?.(() => {
|
|
1094
|
+
if (!waiting.resolved && running.get(channel) === animation && animation.startTime == null && animation.playState === 'running') {
|
|
1095
|
+
(waiting.latest ??= new Map()).set(channel, now());
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
999
1099
|
} else {
|
|
1000
1100
|
// One clock: the keyframes were sampled from `time`.
|
|
1001
1101
|
animation.startTime = time;
|
|
@@ -1445,7 +1545,9 @@ export function createAnimator(element, options = {}) {
|
|
|
1445
1545
|
for (const channel of start === 'commit' ? [] : channels) {
|
|
1446
1546
|
for (const property of CHANNELS[channel]) {
|
|
1447
1547
|
const segment = segments.get(property);
|
|
1448
|
-
|
|
1548
|
+
// A call's first frame puts its channels on screen, even before the
|
|
1549
|
+
// browser reports the start. So such a channel is not at rest either.
|
|
1550
|
+
if (segment != null && time < endOf(property, segment) && (segment.group == null || segment.group.resolved || shownSince(property, segment) != null)) {
|
|
1449
1551
|
return null;
|
|
1450
1552
|
}
|
|
1451
1553
|
}
|
|
@@ -1614,6 +1716,17 @@ export function createAnimator(element, options = {}) {
|
|
|
1614
1716
|
if (!group.resolved && group.madeInFrame !== true && now() - (group.task?.first ?? group.provisional) <= LATE_START_MS && group.animations.some(animation => animation.startTime == null && animation.playState === 'running')) {
|
|
1615
1717
|
resolveGroup(group, now());
|
|
1616
1718
|
}
|
|
1719
|
+
// The browser's start is still unread. The compositor starts the call
|
|
1720
|
+
// near this frame, so each moving channel's reads take the curve from
|
|
1721
|
+
// now until the browser tells its start.
|
|
1722
|
+
if (!group.resolved) {
|
|
1723
|
+
for (const channel of group.channels) {
|
|
1724
|
+
const animation = running.get(channel);
|
|
1725
|
+
if (animation != null && group.animations.includes(animation) && animation.startTime == null && animation.playState === 'running') {
|
|
1726
|
+
(group.latest ??= new Map()).set(channel, now());
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1617
1730
|
});
|
|
1618
1731
|
ready.then(() => syncGroup(group), () => settleCancelled(group));
|
|
1619
1732
|
};
|
|
@@ -2822,8 +2935,10 @@ export function createAnimator(element, options = {}) {
|
|
|
2822
2935
|
}
|
|
2823
2936
|
owners.add(segment.owner);
|
|
2824
2937
|
// A curve still waiting for the browser's start stays in its call:
|
|
2825
|
-
// it starts with that call's commit.
|
|
2826
|
-
|
|
2938
|
+
// it starts with that call's commit. A curve whose call had its first
|
|
2939
|
+
// frame is on screen already, so it leaves the call (leaveWaitingCall).
|
|
2940
|
+
const latest = shownSince(property, segment);
|
|
2941
|
+
const group = latest == null && segment.group != null && !segment.group.resolved ? segment.group : undefined;
|
|
2827
2942
|
const replace = next => {
|
|
2828
2943
|
if (group != null) {
|
|
2829
2944
|
const index = group.segments.indexOf(segment);
|
|
@@ -2838,6 +2953,9 @@ export function createAnimator(element, options = {}) {
|
|
|
2838
2953
|
if (segment.spring != null) {
|
|
2839
2954
|
const from = valueAt(property, time) + delta;
|
|
2840
2955
|
const velocity = velocityAt(property, time);
|
|
2956
|
+
if (latest != null) {
|
|
2957
|
+
leaveWaitingCall(segment, CHANNEL_OF[property], latest);
|
|
2958
|
+
}
|
|
2841
2959
|
const curve = solveSpring(toSpring(segment.spring), {
|
|
2842
2960
|
from,
|
|
2843
2961
|
to: segment.target,
|
|
@@ -2857,6 +2975,9 @@ export function createAnimator(element, options = {}) {
|
|
|
2857
2975
|
spring: segment.spring
|
|
2858
2976
|
});
|
|
2859
2977
|
} else {
|
|
2978
|
+
if (latest != null) {
|
|
2979
|
+
leaveWaitingCall(segment, CHANNEL_OF[property], latest);
|
|
2980
|
+
}
|
|
2860
2981
|
replace({
|
|
2861
2982
|
...segment,
|
|
2862
2983
|
target: segment.target + delta,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file paging.ts
|
|
3
|
+
* @input A release velocity, a settle's start, end and velocity, and the UIKit
|
|
4
|
+
* paging constants
|
|
5
|
+
* @output Exports `pagingSettleVelocity`, `solvePaging` (UIKit's paging settle
|
|
6
|
+
* as a curve the animator plays) and `solveAnimatedPageScroll`
|
|
7
|
+
* @position Pure math, with no DOM and no React
|
|
8
|
+
*
|
|
9
|
+
* SYNC: When modified, update:
|
|
10
|
+
* - /packages/core/src/motion/paging.test.ts
|
|
11
|
+
* - /packages/core/src/motion/README.md
|
|
12
|
+
*/
|
|
13
|
+
import type { MotionCurve } from './animator.js';
|
|
14
|
+
/**
|
|
15
|
+
* The velocity a paging settle starts at. It is the release velocity that every
|
|
16
|
+
* gesture reads, zeroed below `velocityFloor`. The page choice reads the
|
|
17
|
+
* release velocity itself.
|
|
18
|
+
*/
|
|
19
|
+
export declare function pagingSettleVelocity(velocity: number): number;
|
|
20
|
+
/** A paging settle: the curve and where it ends. */
|
|
21
|
+
export interface PagingCurve extends MotionCurve {
|
|
22
|
+
readonly from: number;
|
|
23
|
+
readonly to: number;
|
|
24
|
+
/** Integration steps the settle took. */
|
|
25
|
+
readonly steps: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* UIKit's paging settle from `from` (px), moving at `velocity` (px/s), onto
|
|
29
|
+
* `to`. It steps `paging.integrator` `stepsPerSecond` times a second and ends
|
|
30
|
+
* exactly on `to`. The same motion returns an overscrolled pager to its first
|
|
31
|
+
* or last page.
|
|
32
|
+
*
|
|
33
|
+
* Positions are content offsets along the paging axis, 0 at page 0 and growing
|
|
34
|
+
* toward later pages. Velocities are px/s of that offset.
|
|
35
|
+
*
|
|
36
|
+
* No closed form reproduces the per-frame stepping, so the settle integrates
|
|
37
|
+
* once into a table, and the curve reads the table. A release needs at most
|
|
38
|
+
* about 400 steps, well under a millisecond of work.
|
|
39
|
+
*
|
|
40
|
+
* The release velocity enters in px per millisecond per step, as UIKit hands it
|
|
41
|
+
* to the integrator. At 960 steps a second, the content starts at 96 % of the
|
|
42
|
+
* finger's speed, as in UIKit.
|
|
43
|
+
*/
|
|
44
|
+
export declare function solvePaging({ from, velocity, to, }: {
|
|
45
|
+
from: number;
|
|
46
|
+
velocity: number;
|
|
47
|
+
to: number;
|
|
48
|
+
}): PagingCurve;
|
|
49
|
+
/**
|
|
50
|
+
* `setContentOffset(_:animated:)`: `paging.animatedScroll.duration` on a
|
|
51
|
+
* sinusoidal ease-in-out, whatever the distance. UIKit starts it from the
|
|
52
|
+
* current offset and drops any velocity, as here.
|
|
53
|
+
*/
|
|
54
|
+
export declare function solveAnimatedPageScroll({ from, to, }: {
|
|
55
|
+
from: number;
|
|
56
|
+
to: number;
|
|
57
|
+
}): MotionCurve;
|
|
58
|
+
//# sourceMappingURL=paging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../../src/motion/paging.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAG5C;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,oDAAoD;AACpD,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,EAAE,GACH,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,WAAW,CA6Cd;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,EAAE,GACH,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,WAAW,CAmBd"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file paging.ts
|
|
5
|
+
* @input A release velocity, a settle's start, end and velocity, and the UIKit
|
|
6
|
+
* paging constants
|
|
7
|
+
* @output Exports `pagingSettleVelocity`, `solvePaging` (UIKit's paging settle
|
|
8
|
+
* as a curve the animator plays) and `solveAnimatedPageScroll`
|
|
9
|
+
* @position Pure math, with no DOM and no React
|
|
10
|
+
*
|
|
11
|
+
* SYNC: When modified, update:
|
|
12
|
+
* - /packages/core/src/motion/paging.test.ts
|
|
13
|
+
* - /packages/core/src/motion/README.md
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { paging } from "./uikit/paging.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The velocity a paging settle starts at. It is the release velocity that every
|
|
20
|
+
* gesture reads, zeroed below `velocityFloor`. The page choice reads the
|
|
21
|
+
* release velocity itself.
|
|
22
|
+
*/
|
|
23
|
+
export function pagingSettleVelocity(velocity) {
|
|
24
|
+
return Math.abs(velocity) < paging.release.velocityFloor ? 0 : velocity;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A paging settle: the curve and where it ends. */
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* UIKit's paging settle from `from` (px), moving at `velocity` (px/s), onto
|
|
31
|
+
* `to`. It steps `paging.integrator` `stepsPerSecond` times a second and ends
|
|
32
|
+
* exactly on `to`. The same motion returns an overscrolled pager to its first
|
|
33
|
+
* or last page.
|
|
34
|
+
*
|
|
35
|
+
* Positions are content offsets along the paging axis, 0 at page 0 and growing
|
|
36
|
+
* toward later pages. Velocities are px/s of that offset.
|
|
37
|
+
*
|
|
38
|
+
* No closed form reproduces the per-frame stepping, so the settle integrates
|
|
39
|
+
* once into a table, and the curve reads the table. A release needs at most
|
|
40
|
+
* about 400 steps, well under a millisecond of work.
|
|
41
|
+
*
|
|
42
|
+
* The release velocity enters in px per millisecond per step, as UIKit hands it
|
|
43
|
+
* to the integrator. At 960 steps a second, the content starts at 96 % of the
|
|
44
|
+
* finger's speed, as in UIKit.
|
|
45
|
+
*/
|
|
46
|
+
export function solvePaging({
|
|
47
|
+
from,
|
|
48
|
+
velocity,
|
|
49
|
+
to
|
|
50
|
+
}) {
|
|
51
|
+
const {
|
|
52
|
+
springPull,
|
|
53
|
+
friction,
|
|
54
|
+
stepsPerSecond,
|
|
55
|
+
restDistance,
|
|
56
|
+
restSpeed
|
|
57
|
+
} = paging.integrator;
|
|
58
|
+
const xs = [from];
|
|
59
|
+
const vs = [velocity / 1000];
|
|
60
|
+
let x = from;
|
|
61
|
+
let v = velocity / 1000;
|
|
62
|
+
// ~10 s of steps: far beyond any settle (≈ 0.35 s from rest).
|
|
63
|
+
const maxSteps = stepsPerSecond * 10;
|
|
64
|
+
let steps = 0;
|
|
65
|
+
while (steps < maxSteps) {
|
|
66
|
+
if (Math.abs(to - x) < restDistance && Math.abs(v) < restSpeed) {
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
v = (v + (to - x) * springPull) * friction;
|
|
70
|
+
x += v;
|
|
71
|
+
steps += 1;
|
|
72
|
+
xs.push(x);
|
|
73
|
+
vs.push(v);
|
|
74
|
+
}
|
|
75
|
+
xs[xs.length - 1] = to;
|
|
76
|
+
vs[vs.length - 1] = 0;
|
|
77
|
+
const duration = steps / stepsPerSecond;
|
|
78
|
+
const last = xs.length - 1;
|
|
79
|
+
const read = (table, t) => {
|
|
80
|
+
if (!(t > 0)) {
|
|
81
|
+
return table[0];
|
|
82
|
+
}
|
|
83
|
+
const s = t * stepsPerSecond;
|
|
84
|
+
if (s >= last) {
|
|
85
|
+
return table[last];
|
|
86
|
+
}
|
|
87
|
+
const i = Math.floor(s);
|
|
88
|
+
const f = s - i;
|
|
89
|
+
return table[i] + (table[i + 1] - table[i]) * f;
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
from,
|
|
93
|
+
to,
|
|
94
|
+
steps,
|
|
95
|
+
duration,
|
|
96
|
+
at: t => read(xs, t),
|
|
97
|
+
// px per step × steps per second
|
|
98
|
+
velocity: t => read(vs, t) * stepsPerSecond
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* `setContentOffset(_:animated:)`: `paging.animatedScroll.duration` on a
|
|
104
|
+
* sinusoidal ease-in-out, whatever the distance. UIKit starts it from the
|
|
105
|
+
* current offset and drops any velocity, as here.
|
|
106
|
+
*/
|
|
107
|
+
export function solveAnimatedPageScroll({
|
|
108
|
+
from,
|
|
109
|
+
to
|
|
110
|
+
}) {
|
|
111
|
+
const {
|
|
112
|
+
duration
|
|
113
|
+
} = paging.animatedScroll;
|
|
114
|
+
const distance = to - from;
|
|
115
|
+
return {
|
|
116
|
+
duration,
|
|
117
|
+
at: t => {
|
|
118
|
+
const u = Math.min(1, Math.max(0, t / duration));
|
|
119
|
+
return from + distance * (1 - Math.cos(Math.PI * u)) / 2;
|
|
120
|
+
},
|
|
121
|
+
velocity: t => {
|
|
122
|
+
if (t <= 0 || t >= duration) {
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
return distance * Math.PI / (2 * duration) * Math.sin(Math.PI * t / duration);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @file index.ts
|
|
3
3
|
* @input The domain files of the UIKit constants table
|
|
4
4
|
* @output Re-exports `springs` and one constant per spring (`SHEET_PRESENT_SPRING`,
|
|
5
|
-
* …), `scroll`, `timing`, `navigation` and the
|
|
5
|
+
* …), `scroll`, `timing`, `navigation`, the `slider` domain and the
|
|
6
6
|
* gesture thresholds (one `UIKIT_*` group per recognizer, their union
|
|
7
7
|
* `UIKIT_GESTURES`, and the haptic tables)
|
|
8
8
|
* @position Entry of the UIKit constants table (motion/uikit). Internal to
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
export { HAPTIC_FEEDBACK_KINDS, HAPTIC_VIBRATION_PATTERNS, UIKIT_CLICK, UIKIT_CONTROL, UIKIT_GESTURES, UIKIT_LONG_PRESS, UIKIT_PAN, UIKIT_PINCH, UIKIT_PRESS, UIKIT_ROTATION, UIKIT_SCREEN_EDGE_PAN, UIKIT_SWIPE, UIKIT_TAP, UIKIT_VELOCITY, type GestureConstant, type GestureConstantUnit, type HapticFeedbackKind, } from './gestures.js';
|
|
20
20
|
export { navigation, registerNavigationTable } from './navigation.js';
|
|
21
21
|
export { registerScrollTable, scroll } from './scroll.js';
|
|
22
|
+
export { slider } from './slider.js';
|
|
22
23
|
export { ACTION_SHEET_DISMISS_SPRING, ACTION_SHEET_PRESENT_SPRING, ALERT_DISMISS_SPRING, ALERT_PRESENT_SPRING, BANNER_SPRING, CONTEXT_MENU_DISMISS_SPRING, CONTEXT_MENU_LIFT_SPRING, CONTEXT_MENU_MORPH_SPRING, DIRECT_CHANGE_SPRING, EMPHASIS_SPRING, FINGER_TRACKING_SPRING, KEYBOARD_SPRING, MENU_CLOSE_SPRING, MENU_OPEN_SPRING, MENU_REDUCED_MOTION_SPRING, NAVIGATION_BAR_ELEMENTS_SPRING, NAVIGATION_INTERACTIVE_POP_FINISH_SPRING, NAVIGATION_POP_SPRING, NAVIGATION_PUSH_SPRING, QUICK_CHANGE_SPRING, SEGMENTED_THUMB_SPRING, SETTLE_SPRING, SHEET_DETENT_SPRING, SHEET_DISMISS_SPRING, SHEET_DISMISS_SWIPE_SPRING, SHEET_PRESENT_SPRING, SHEET_RELEASE_FAST_SPRING, STATE_CHANGE_SPRING, SUB_MENU_BACK_SPRING, SUB_MENU_OPEN_SPRING, SWITCH_THUMB_MOVE_SPRING, SWITCH_THUMB_STRETCH_SPRING, TIMED_CHANGE_SPRING, VIEW_CHANGE_SPRING, registerSpringsTable, springs, } from './springs.js';
|
|
23
24
|
export { registerTimingTable, timing } from './timing.js';
|
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/motion/uikit/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,UAAU,EAAE,uBAAuB,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,EAAC,mBAAmB,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AACrD,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,8BAA8B,EAC9B,wCAAwC,EACxC,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,mBAAmB,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/motion/uikit/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,UAAU,EAAE,uBAAuB,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,EAAC,mBAAmB,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AACrD,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,8BAA8B,EAC9B,wCAAwC,EACxC,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,mBAAmB,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @file index.ts
|
|
5
5
|
* @input The domain files of the UIKit constants table
|
|
6
6
|
* @output Re-exports `springs` and one constant per spring (`SHEET_PRESENT_SPRING`,
|
|
7
|
-
* …), `scroll`, `timing`, `navigation` and the
|
|
7
|
+
* …), `scroll`, `timing`, `navigation`, the `slider` domain and the
|
|
8
8
|
* gesture thresholds (one `UIKIT_*` group per recognizer, their union
|
|
9
9
|
* `UIKIT_GESTURES`, and the haptic tables)
|
|
10
10
|
* @position Entry of the UIKit constants table (motion/uikit). Internal to
|
|
@@ -22,5 +22,6 @@
|
|
|
22
22
|
export { HAPTIC_FEEDBACK_KINDS, HAPTIC_VIBRATION_PATTERNS, UIKIT_CLICK, UIKIT_CONTROL, UIKIT_GESTURES, UIKIT_LONG_PRESS, UIKIT_PAN, UIKIT_PINCH, UIKIT_PRESS, UIKIT_ROTATION, UIKIT_SCREEN_EDGE_PAN, UIKIT_SWIPE, UIKIT_TAP, UIKIT_VELOCITY } from "./gestures.js";
|
|
23
23
|
export { navigation, registerNavigationTable } from "./navigation.js";
|
|
24
24
|
export { registerScrollTable, scroll } from "./scroll.js";
|
|
25
|
+
export { slider } from "./slider.js";
|
|
25
26
|
export { ACTION_SHEET_DISMISS_SPRING, ACTION_SHEET_PRESENT_SPRING, ALERT_DISMISS_SPRING, ALERT_PRESENT_SPRING, BANNER_SPRING, CONTEXT_MENU_DISMISS_SPRING, CONTEXT_MENU_LIFT_SPRING, CONTEXT_MENU_MORPH_SPRING, DIRECT_CHANGE_SPRING, EMPHASIS_SPRING, FINGER_TRACKING_SPRING, KEYBOARD_SPRING, MENU_CLOSE_SPRING, MENU_OPEN_SPRING, MENU_REDUCED_MOTION_SPRING, NAVIGATION_BAR_ELEMENTS_SPRING, NAVIGATION_INTERACTIVE_POP_FINISH_SPRING, NAVIGATION_POP_SPRING, NAVIGATION_PUSH_SPRING, QUICK_CHANGE_SPRING, SEGMENTED_THUMB_SPRING, SETTLE_SPRING, SHEET_DETENT_SPRING, SHEET_DISMISS_SPRING, SHEET_DISMISS_SWIPE_SPRING, SHEET_PRESENT_SPRING, SHEET_RELEASE_FAST_SPRING, STATE_CHANGE_SPRING, SUB_MENU_BACK_SPRING, SUB_MENU_OPEN_SPRING, SWITCH_THUMB_MOVE_SPRING, SWITCH_THUMB_STRETCH_SPRING, TIMED_CHANGE_SPRING, VIEW_CHANGE_SPRING, registerSpringsTable, springs } from "./springs.js";
|
|
26
27
|
export { registerTimingTable, timing } from "./timing.js";
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file paging.ts
|
|
3
|
+
* @input Nothing; data only
|
|
4
|
+
* @output Exports `paging`, the measured constants of a paging UIScrollView
|
|
5
|
+
* @position The paging domain of the UIKit constants table (motion/uikit). Only
|
|
6
|
+
* core reads it, so the `uikit` namespace does not re-export it
|
|
7
|
+
*
|
|
8
|
+
* SYNC: When modified, update:
|
|
9
|
+
* - /packages/core/src/motion/MEASUREMENTS.md (measurement tasks)
|
|
10
|
+
* - /packages/core/src/motion/paging.ts and paging.test.ts
|
|
11
|
+
*/
|
|
12
|
+
export declare const paging: {
|
|
13
|
+
/**
|
|
14
|
+
* After the lift, one model moves the content: the settle onto the chosen
|
|
15
|
+
* page and the return from an overscroll. Each display frame runs floor(frame
|
|
16
|
+
* interval in ms) steps of 1 ms:
|
|
17
|
+
*
|
|
18
|
+
* v = (v + (target − x) · springPull) · friction; x += v (v: pt per step)
|
|
19
|
+
*
|
|
20
|
+
* A 60 Hz frame runs 16 steps, not 16.67. With these values, the model
|
|
21
|
+
* replays eight captured releases to 0.20 pt RMS. It replays five overscroll
|
|
22
|
+
* returns to 0.16–0.33 pt RMS (402 pt pages, iOS 26.2, 3× screen). Without
|
|
23
|
+
* the floor, the error is 1.0 pt RMS, with a systematic shape.
|
|
24
|
+
*/
|
|
25
|
+
readonly integrator: {
|
|
26
|
+
/**
|
|
27
|
+
* Velocity added per 1 ms step, per point of distance to the target page
|
|
28
|
+
* (pt per step²).
|
|
29
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026.
|
|
30
|
+
* `_pagingSpringPull` reads the same on a 402 pt paging UIScrollView and
|
|
31
|
+
* on UIPageViewController's scroll view. It replays 8 captured settles to
|
|
32
|
+
* 0.20 pt RMS.
|
|
33
|
+
*/
|
|
34
|
+
readonly springPull: 0.000284858;
|
|
35
|
+
/**
|
|
36
|
+
* Velocity kept per step after the pull (`_pagingFriction`, equal to
|
|
37
|
+
* `_defaultPagingFriction`).
|
|
38
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026. Both read
|
|
39
|
+
* the same on the two scroll views of `springPull`, and they replay with
|
|
40
|
+
* it.
|
|
41
|
+
*/
|
|
42
|
+
readonly friction: 0.970815;
|
|
43
|
+
/**
|
|
44
|
+
* Integration steps per second: floor(16.67 ms) = 16 steps per 60 Hz frame,
|
|
45
|
+
* and floor(8.33 ms) = 8 per 120 Hz frame, so 960.
|
|
46
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026. In a 60 fps
|
|
47
|
+
* log of 8 releases at rest, floored stepping fits to 0.20 pt RMS.
|
|
48
|
+
* Unfloored stepping fits to 1.0 pt RMS.
|
|
49
|
+
*/
|
|
50
|
+
readonly stepsPerSecond: 960;
|
|
51
|
+
/**
|
|
52
|
+
* A settle ends exactly on the page once the remaining distance is below
|
|
53
|
+
* this many points and the step velocity is below `restSpeed`.
|
|
54
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026. The
|
|
55
|
+
* captured settles jump the last 0.33 pt onto the page about 0.35 s after
|
|
56
|
+
* a release at rest.
|
|
57
|
+
*/
|
|
58
|
+
readonly restDistance: 0.5;
|
|
59
|
+
/**
|
|
60
|
+
* Step velocity (pt per step) below which a settle may end.
|
|
61
|
+
* @source GUESS — the captured settles end at about 0.04 pt per step;
|
|
62
|
+
* the threshold is not observable more finely at 60 fps
|
|
63
|
+
* @measure M-PG12
|
|
64
|
+
*/
|
|
65
|
+
readonly restSpeed: 0.05;
|
|
66
|
+
};
|
|
67
|
+
readonly release: {
|
|
68
|
+
/**
|
|
69
|
+
* Released slower than `advanceSpeed`, the scroll view settles on the page
|
|
70
|
+
* nearest the content position: past half a page, the next one.
|
|
71
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026. In releases
|
|
72
|
+
* at rest from page 1, content at 48.5 % of the page stays, and 57.5 %
|
|
73
|
+
* goes to the next page. On a second 402 pt pager, 45 % stays and 55 %
|
|
74
|
+
* advances.
|
|
75
|
+
*/
|
|
76
|
+
readonly commitFraction: 0.5;
|
|
77
|
+
/**
|
|
78
|
+
* Released at least this fast (pt/s), the scroll view pages in the
|
|
79
|
+
* direction of the velocity, from any content position. A flick from 6 % of
|
|
80
|
+
* the page advances. The speed is UIPanGestureRecognizer's velocity at the
|
|
81
|
+
* last movement, and it never decays. The scroll view's
|
|
82
|
+
* `_horizontalVelocity` equals it at every sample. A drag held still for
|
|
83
|
+
* 397 ms before the lift still pages at the speed it had.
|
|
84
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026. Steady
|
|
85
|
+
* releases at 10, 25 and 40 % of a 402 pt page: 292.7, 295.3 and 298.6
|
|
86
|
+
* pt/s stay; 310.7, 316.4 and 329.9 advance. The result is the same at
|
|
87
|
+
* every position: a threshold, not a projection.
|
|
88
|
+
*/
|
|
89
|
+
readonly advanceSpeed: 300;
|
|
90
|
+
/**
|
|
91
|
+
* A settle velocity slower than this (pt/s) is zeroed, so the settle starts
|
|
92
|
+
* at rest. It is paging's own tuning on the one release velocity that every
|
|
93
|
+
* gesture reads.
|
|
94
|
+
* @source GUESS — the middle of the measured (200, 249] bracket. In the
|
|
95
|
+
* UIKit lab (iOS 26.2 simulator, Oct 23 2026),
|
|
96
|
+
* `scrollViewWillEndDragging` reads 0 for steady releases at 175 and 200
|
|
97
|
+
* pt/s. It reads 0.249 pt/ms for a release at 249 pt/s.
|
|
98
|
+
* @measure M-PG13
|
|
99
|
+
*/
|
|
100
|
+
readonly velocityFloor: 225;
|
|
101
|
+
/**
|
|
102
|
+
* Pages a release may travel from the page the drag started on, at any
|
|
103
|
+
* speed and drag distance.
|
|
104
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026. A drag of
|
|
105
|
+
* 1.5 pages from page 1 lands on page 2 at release speeds of 0, 600 and
|
|
106
|
+
* 3000 pt/s.
|
|
107
|
+
*/
|
|
108
|
+
readonly maxPagesFromStart: 1;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* A finger that lands on a settling pager does not stop it at once. The
|
|
112
|
+
* settle runs on for about this long, then the content holds under the
|
|
113
|
+
* finger. Lifted without a move, the content settles again on the nearest
|
|
114
|
+
* page.
|
|
115
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026. After
|
|
116
|
+
* touch-downs 60 and 160 ms into a settle, the content moved on for 82.6
|
|
117
|
+
* and 87.5 ms (5 frames), then held.
|
|
118
|
+
*/
|
|
119
|
+
readonly catchStopMs: 85;
|
|
120
|
+
/**
|
|
121
|
+
* A horizontal pager's pan begins only for a drag within atan(1 ÷ this) of
|
|
122
|
+
* horizontal (26.6° for 2). A steeper drag goes to the vertical scroll around
|
|
123
|
+
* it. Between 26.6° and 45°, neither moves.
|
|
124
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026. A scroll
|
|
125
|
+
* view's directional lock holds the major axis up to 25° and frees it from
|
|
126
|
+
* 30°. An inline calendar pager in a sheet pages at 20° from horizontal. At
|
|
127
|
+
* 35° and 45°, it moves neither itself nor the sheet, and it leaves 55° to
|
|
128
|
+
* the sheet.
|
|
129
|
+
*/
|
|
130
|
+
readonly panAxisRatio: 2;
|
|
131
|
+
readonly animatedScroll: {
|
|
132
|
+
/**
|
|
133
|
+
* `setContentOffset(_:animated:)` duration. It is the same for one page and
|
|
134
|
+
* for five, as for a page control's tap.
|
|
135
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026.
|
|
136
|
+
* `_contentOffsetAnimationDuration` reads 0.3, and five animated moves of
|
|
137
|
+
* 1 to 5 pages each last 0.30 s.
|
|
138
|
+
*/
|
|
139
|
+
readonly duration: 0.3;
|
|
140
|
+
/**
|
|
141
|
+
* Its curve is a sinusoidal ease-in-out: x = from + (to − from) · (1 − cos
|
|
142
|
+
* πu) ÷ 2, for u = t ÷ duration.
|
|
143
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026. The five
|
|
144
|
+
* moves fit the sinusoid to 0.14–0.51 pt RMS, and a 2010 pt move fits to
|
|
145
|
+
* 0.20 pt. The curve easeInEaseOut (0.42, 0, 0.58, 1) misses by 7.7 pt.
|
|
146
|
+
*/
|
|
147
|
+
readonly curve: "sineInOut";
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Past the first or last page, the content follows the finger through the
|
|
151
|
+
* scroll view's rubber band (scroll.rubberBand.coefficient), with d = the
|
|
152
|
+
* page width. It returns on the integrator above.
|
|
153
|
+
* @source measured: UIKit lab, iOS 26.2 simulator, Oct 23 2026. A pan of 90
|
|
154
|
+
* pt past page 0 shows 42.7–45 pt, and 290 pt shows 114.3 pt. The formula
|
|
155
|
+
* gives 44.1 and 114.2, with c 0.55 and d 402. The return replays on the
|
|
156
|
+
* integrator to 0.16–0.33 pt RMS.
|
|
157
|
+
*/
|
|
158
|
+
readonly rubberBandDimension: "pageWidth";
|
|
159
|
+
};
|
|
160
|
+
//# sourceMappingURL=paging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../../../src/motion/uikit/paging.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,MAAM;IACjB;;;;;;;;;;;OAWG;;QAED;;;;;;;WAOG;;QAEH;;;;;;WAMG;;QAEH;;;;;;WAMG;;QAEH;;;;;;WAMG;;QAEH;;;;;WAKG;;;;QAIH;;;;;;;WAOG;;QAEH;;;;;;;;;;;WAWG;;QAEH;;;;;;;;;WASG;;QAEH;;;;;;WAMG;;;IAGL;;;;;;;;OAQG;;IAEH;;;;;;;;;OASG;;;QAGD;;;;;;WAMG;;QAEH;;;;;;WAMG;;;IAGL;;;;;;;;OAQG;;CAEK,CAAC"}
|