Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
diff --git a/node_modules/react-native-collapsible-tab-view/lib/module/Container.js b/node_modules/react-native-collapsible-tab-view/lib/module/Container.js
index a1b2c3d..b4c5d6e 100644
--- a/node_modules/react-native-collapsible-tab-view/lib/module/Container.js
+++ b/node_modules/react-native-collapsible-tab-view/lib/module/Container.js
@@ -233,7 +233,24 @@ export const Container = React.memo(
getCurrentIndex: () => {
return index.value;
- }
- }), // eslint-disable-next-line react-hooks/exhaustive-deps
- [onTabPress]);
+ },
+ scrollToTop: () => {
+ scrollYCurrent.value = 0;
+ const resetMap = {};
+ for (const name of tabNamesArray) {
+ resetMap[name] = 0;
+ }
+ scrollY.value = { ...scrollY.value, ...resetMap };
+ const currentName = tabNames.value[index.value];
+ const ref = refMap[currentName];
+ if (ref) {
+ runOnUISync(scrollToImpl, ref, 0, -contentInset, false);
+ }
+ toggleSyncScrollFrame(true);
+ }
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
+ [onTabPress, toggleSyncScrollFrame]);
Comment on lines +5 to +27
diff --git a/node_modules/react-native-collapsible-tab-view/lib/typescript/src/types.d.ts b/node_modules/react-native-collapsible-tab-view/lib/typescript/src/types.d.ts
index 38df065..c780667 100644
--- a/node_modules/react-native-collapsible-tab-view/lib/typescript/src/types.d.ts
Expand All @@ -6,7 +33,6 @@ index 38df065..c780667 100644
setIndex: (index: number) => boolean;
getFocusedTab: () => T;
getCurrentIndex: () => number;
+ scrollResync: () => void;
+ scrollToTop: () => void;
};
export type CollapsibleRef<T extends TabName = TabName> = RefHandler<T> | undefined;
Expand All @@ -18,21 +44,21 @@ index 9ec4cfe..3a068c9 100644
@@ -227,7 +227,9 @@ export const Container = React.memo(
const toggleSyncScrollFrame = (toggle: boolean) =>
syncScrollFrame.setActive(toggle)
const lastSyncBucketRef = React.useRef(0)
const syncScrollFrame = useFrameCallback(({ timeSinceFirstFrame }) => {
- syncCurrentTabScrollPosition()
+ if (timeSinceFirstFrame % 100 === 0) {
+ const bucket = Math.floor(timeSinceFirstFrame / 100)
+ if (bucket !== lastSyncBucketRef.current) {
+ lastSyncBucketRef.current = bucket
+ syncCurrentTabScrollPosition()
+ }
Comment on lines +47 to 54
if (timeSinceFirstFrame > 1500) {
scheduleOnRN(toggleSyncScrollFrame, false)
}
@@ -343,9 +345,24 @@ export const Container = React.memo(
@@ -343,9 +345,27 @@ export const Container = React.memo(
getCurrentIndex: () => {
return index.value
},
+ scrollResync: () => {
+ toggleSyncScrollFrame(true)
+ },
+ scrollToTop: () => {
+ scrollYCurrent.value = 0
+ const resetMap: Record<string, number> = {}
Expand All @@ -42,15 +68,17 @@ index 9ec4cfe..3a068c9 100644
+ scrollY.value = { ...scrollY.value, ...resetMap }
+ const currentName = tabNames.value[index.value]
+ const ref = refMap[currentName]
+ runOnUISync(scrollToImpl, ref, 0, -contentInset, false)
+ if (ref) {
+ runOnUISync(scrollToImpl, ref, 0, -contentInset, false)
+ }
+ toggleSyncScrollFrame(true)
+ },
Comment on lines 58 to 75
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
- [onTabPress]
+ [onTabPress, toggleSyncScrollFrame]
)

return (
diff --git a/node_modules/react-native-collapsible-tab-view/src/types.ts b/node_modules/react-native-collapsible-tab-view/src/types.ts
index 00fbafc..dee894c 100644
Expand All @@ -60,8 +88,7 @@ index 00fbafc..dee894c 100644
setIndex: (index: number) => boolean
getFocusedTab: () => T
getCurrentIndex: () => number
+ scrollResync: () => void
+ scrollToTop: () => void
}

export type CollapsibleRef<T extends TabName = TabName> =
Loading