decord/source/modules/collectibles/native/hooks/useScrollToInitialIndexOnce.tsx

48 lines
1.5 KiB
TypeScript
Raw Normal View History

// Module ID: 15939
// Function ID: 15940
// Name: useScrollToInitialIndexOnce
2026-07-29 08:29:29 +00:00
// Dependencies: [19, 2]
2026-07-20 16:05:17 +00:00
// Exports: useScrollToInitialIndexOnce
// Module 15939 (useScrollToInitialIndexOnce)
import noop from "module_19" /* 19 */;
2026-07-23 10:11:24 +00:00
const size = fn(2);
const result = size.fileFinishedImporting("modules/collectibles/native/hooks/useScrollToInitialIndexOnce.tsx");
2026-07-20 16:05:17 +00:00
export const INITIAL_SCROLL_DELAY_MS = 100;
export const useScrollToInitialIndexOnce = function useScrollToInitialIndexOnce(initialScrollIndex) {
initialScrollIndex = initialScrollIndex.initialScrollIndex;
const shouldScroll = initialScrollIndex.shouldScroll;
const flashListRef = initialScrollIndex.flashListRef;
let num = initialScrollIndex.afterMs;
if (num === undefined) {
num = 100;
}
const resetKey = initialScrollIndex.resetKey;
noop.useRef(false);
noop.useRef(resetKey);
2026-07-20 16:05:17 +00:00
const items = [shouldScroll, initialScrollIndex, num, flashListRef, resetKey];
const effect = noop.useEffect(() => {
2026-07-20 16:05:17 +00:00
if (ref2.current !== resetKey) {
ref2.current = resetKey;
ref.current = false;
}
2026-07-29 08:29:29 +00:00
let tmp2 = null != initialScrollIndex && shouldScroll;
if (tmp2) {
tmp2 = !ref.current;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp2) {
2026-07-20 16:05:17 +00:00
ref.current = true;
const _setTimeout = setTimeout;
const timerId = setTimeout(() => {
2026-07-29 08:29:29 +00:00
const current = ref.current;
if (current != null) {
const obj = { animated: true, index };
2026-07-20 16:05:17 +00:00
current.scrollToIndex(obj);
}
}, num);
}
}, items);
};