@onekeyfe/react-native-pager-view 6.7.0-2 → 6.7.0-3
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/README.md +9 -0
- package/docs/SPEC.md +46 -0
- package/lib/module/CollapsiblePagerView.web.js +428 -37
- package/lib/module/NativeScroller.web.js +16 -3
- package/lib/module/WebCollapsiblePagerPage.js +182 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.web.js +2 -0
- package/lib/typescript/src/CollapsiblePagerView.web.d.ts +64 -3
- package/lib/typescript/src/WebCollapsiblePagerPage.d.ts +42 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.web.d.ts +4 -0
- package/package.json +2 -2
- package/src/CollapsiblePagerView.web.tsx +638 -49
- package/src/NativeScroller.web.tsx +24 -2
- package/src/WebCollapsiblePagerPage.tsx +258 -0
- package/src/index.tsx +4 -0
- package/src/index.web.tsx +4 -0
package/README.md
CHANGED
|
@@ -67,6 +67,15 @@ Web scroll child can opt in by exposing a DOM element with
|
|
|
67
67
|
`data-collapsible-pager-scroll`. CSS scroll timelines drive header/sticky
|
|
68
68
|
movement, so React is not updated on each vertical scroll frame.
|
|
69
69
|
|
|
70
|
+
On Web, `WebCollapsiblePagerView` is an explicit root export of the existing Web
|
|
71
|
+
pager. It measures Header and sticky content when their heights are omitted.
|
|
72
|
+
`isActive` describes route visibility; the pager preserves a pending scroll
|
|
73
|
+
target across a short or temporarily hidden page and retries when real content
|
|
74
|
+
geometry becomes ready. `useWebCollapsiblePagerPage()` exposes the selected
|
|
75
|
+
page's scroll owner, visible metrics, content registration and pending target
|
|
76
|
+
to descendants. These Web-only APIs require a DOM when mounted. Native callers
|
|
77
|
+
continue to use `CollapsiblePagerView`.
|
|
78
|
+
|
|
70
79
|
On iOS and Android, `nativeTabBar` renders the tab bar natively and
|
|
71
80
|
`onNativeTabPress` reports presses. By default, adjacent tab presses animate and
|
|
72
81
|
non-adjacent presses jump directly to the target without passing intermediate
|
package/docs/SPEC.md
CHANGED
|
@@ -841,3 +841,49 @@ The native Home Spotlight adapter consumes this snapshot in the main UI runtime
|
|
|
841
841
|
Removing a page or clearing the page collection MUST cancel the active horizontal transition and its temporary display snapshots before notifying the adapter. Cancellation MUST NOT rewrite the shared Header collapse or surviving pages' saved body reading memory. The previous observed owner MUST be detached without committing an offset under a shifted page key.
|
|
842
842
|
|
|
843
843
|
An empty adapter MUST reject transition starts and transition completion without coercing an index into an empty range. The selected index uses zero as an empty-state sentinel; nonempty mutations clamp it to the remaining valid range. Readding pages MUST allow a fresh selection and MUST NOT resume a removed transition source. Conformance requires actual Android active-transition → zero-pages → readd/selection regression and remaining-page mutation checks; structural checks and compilation alone do not establish runtime behavior.
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
## Web parent-scroll owner identity
|
|
847
|
+
|
|
848
|
+
Web Header and sticky overlays use the named scroll timeline only when the
|
|
849
|
+
browser supports every CSS property needed for that linkage. Otherwise, the
|
|
850
|
+
active scroll owner's offset drives the same clamped Header collapse in JS:
|
|
851
|
+
`C = min(max(scrollTop, 0), max(headerHeight, 0))`. The fallback keeps the
|
|
852
|
+
existing page owner, insets, body offset memory, and sticky anchor. It updates
|
|
853
|
+
when scrolling, selecting or restoring a page, replacing an owner, or changing
|
|
854
|
+
Header height, and releases its listener when that owner detaches. An inactive
|
|
855
|
+
page cannot move the visible Header. This is a Web-only compatibility path; no
|
|
856
|
+
native behavior or public prop changes.
|
|
857
|
+
When an overlay forwards a vertical wheel or touch scroll to the active owner,
|
|
858
|
+
the owner receives the same internal user-input notification used by route
|
|
859
|
+
restoration to cancel an obsolete pending offset.
|
|
860
|
+
|
|
861
|
+
On Web, an explicitly marked NativeScroller is selected before an implicit NativeList viewport. There is one vertical owner per page; callers using parent-owned NativeList pass that same scroll element as webScrollHost.
|
|
862
|
+
|
|
863
|
+
The existing NativeScroller pagerScrollKey identifies a Web page scroll owner. Changing the key invalidates that page body offset without remounting its React business content. The active owner also resets the shared header collapse and cancels queued old restore/top commands. Inactive owners invalidate their saved body offset without imperative scrolling; selection checks the current identity before restoring. A→B→A identity changes never revive a prior owner offset. Stable keys preserve ordinary page C+B restoration. Current-page top commands continue to affect only the selected page.
|
|
864
|
+
|
|
865
|
+
Identity notifications and DOM owner listeners are internal implementation details, removed when the pager root or owner is replaced/unmounted. No native behavior or public configuration is added.
|
|
866
|
+
|
|
867
|
+
### Web overlay input and keyed-page updates
|
|
868
|
+
|
|
869
|
+
- Header and sticky slots remain overlays: overflow outside the sticky slot may remain visible without adding its portal height to page insets twice.
|
|
870
|
+
- Vertical wheel or touch input over those overlays transfers only to the active page scroll owner when no nested scrollable consumes it. Horizontal controls, editable inputs, and ordinary button/tap behavior retain their own events. Input originating inside the page owner follows native scrolling once.
|
|
871
|
+
- Reordering or removing keyed pages must save the previously configured key and owner, rather than resolving the old selected index against new children. Caller index synchronization preserves keyed body offsets and shared header collapse.
|
|
872
|
+
- For an explicit NativeScroller, Pager chrome insets apply to the existing ScrollView content element, not its viewport. Insets taller than the available window cannot enlarge the scroll viewport. Existing owner/content padding is preserved and restored separately from Pager insets; direct NativeList/page-host fallback retains its prior layout path.
|
|
873
|
+
- The Pager root clips without becoming a programmatically scrollable overflow box. Browser focus and descendant scrollIntoView cannot add a second horizontal page offset outside the selected-page transform.
|
|
874
|
+
|
|
875
|
+
## Web page geometry and route restoration
|
|
876
|
+
|
|
877
|
+
Status: Implemented in Web source and focused tests; browser and native runtime acceptance remain separate.
|
|
878
|
+
|
|
879
|
+
`WebCollapsiblePagerView` is the existing Web `CollapsiblePagerView` class under an explicit root export. Its `isActive` prop defaults to true and represents route visibility, independently of the selected page. The Web-only `useWebCollapsiblePagerPage()` hook returns null outside a Web pager and otherwise exposes `isFocused`, `isRouteActive`, `owner`, `content`, optional `contentHeight`, `width`, `height`, content-relative `scrollTop`, `registerContent`, and read-only `pendingRouteScrollTop`. Native `CollapsiblePagerView`, its bridge, and its props are unchanged. The Web component rejects mounting without a DOM; importing the root or Web module alone must not access DOM globals.
|
|
880
|
+
|
|
881
|
+
Web callers may supply finite nonnegative `headerHeight` and `stickyHeaderHeight`. When omitted or invalid (negative, NaN, or infinite), the SDK measures the natural inner Header and sticky content with `ResizeObserver`; explicit valid values take precedence, including zero. An initial unmeasured zero is not ready for route restoration; a measured empty chrome element may legitimately have zero height. Measurement must not use the constrained slot height as its own input. Height changes update the owned insets before route restoration. Existing explicit-height callers retain their layout path.
|
|
882
|
+
|
|
883
|
+
Each page has one SDK-discovered vertical owner: explicit `NativeScroller`, then implicit NativeList viewport, then page host. Registration accepts a connected content element and optional finite nonnegative explicit height; invalid height metadata is ignored. It does not change DOM layout or make a pending target reachable. A later registration of the same element supersedes an earlier one, and stale cleanup cannot remove it. An explicit-height change schedules geometry measurement even if the element border box is unchanged. Metrics use owner client width; `pinnedBottom = ownerRect.top + max(0, headerHeight - owner.scrollTop) + stickyHeaderHeight`; `visibleTop = max(ownerRect.top, pinnedBottom, contentRect.top if present)`; visible height is `max(0, ownerRect.bottom - visibleTop)` and content-relative scroll top is `max(0, pinnedBottom - contentRect.top)`. Unregistered content falls back to the first owner child. Detached content and callbacks from old owners are ignored. One animation-frame measurement per page coalesces scroll, resize, registration, owner configuration, and active-page changes. Disposal releases observers, listeners, frames, and subscriptions.
|
|
884
|
+
|
|
885
|
+
On active-to-inactive transition, the Web pager freezes the selected logical React page key, `pagerScrollKey` identity, actual owner generation, and last valid raw DOM top. Inactive scroll/geometry changes cannot replace the snapshot. A second blur of the same pending identity preserves the original target. On focus, owner, content, chrome, or inset changes, the pager retries without a timer only when the route is active, that exact key/identity/owner remains selected and connected, the viewport has positive height, the pager has configured the expected insets, and real `scrollHeight - clientHeight` reaches the target. Short content keeps the target pending. Restoration clears pending before one instant scroll and synchronizes the existing shared Header C and per-page body B memory. An idempotent Web `restoreScrollPosition()` returns false while inactive or not ready and true when no target remains or it applies; normal callers need no polling.
|
|
886
|
+
|
|
887
|
+
Valid vertical wheel, scroll keys, scrollbar drag, overlay-forwarded input, accepted NativeList commands, and explicit page-top/sticky-top commands cancel pending route intent through the existing SDK takeover path. As in the prior Web app adapter, any owner `pointerdown` or `touchstart`, including a child target, cancels only route pending; this does not newly commit or clear SDK C+B memory. Geometry-only scroll/resize/scrollend cannot cancel intent. Valid same-offset commands cancel it; invalid or stale commands do not. A matching route target takes priority over automatic tab C+B restoration. Selection of a different key, owner identity reset (including A→B→A), genuine DOM owner replacement, or removal cancels pending; a same-key index reorder preserves it. A same-commit blur and Activity/Offscreen effect disconnect captures the current route target before releasing the owner; repeated disconnects preserve an existing pending target. A temporary React ref null or Activity/Offscreen effect disconnect followed by the identical connected owner preserves the logical route target and owner generation while releasing all observers, listeners, frames, and DOM configuration during disconnect. Restoration is unavailable while disconnected; reconnect remeasures automatic chrome before applying pending. A truly removed pager instance cannot transfer its pending target to a new instance. Older queued tab/top callbacks must validate generation before writing after route restoration or cancellation. The app owns navigation focus and business tab names; the SDK never infers them from escaped React child keys.
|
|
888
|
+
|
|
889
|
+
Platform matrix: Web owns this DOM geometry, registration, route pending, and explicit Web export. iOS and Android keep native scrolling, restoration, and page coordination documented above, with no new prop, native bridge call, JS heap sharing, or process resource. The UI main runtime owns Web state; background runtimes do not deserialize it. Source/type tests establish only Web contract implementation, not browser rendering or native device behavior. Acceptance requires real Web/Desktop route blur, short content then growth, user takeover, dynamic chrome, key reset, and Home/Market scroll regressions.
|