decord/source/modules/collectibles/native/hooks/useScrollToInitialIndexOnce.tsx
github-actions da5b5e5efe chore: update source for alpha 346.6
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4821.js (118.4 MB)
2026-09-12 13:45:10 +00:00

47 lines
1.5 KiB
TypeScript

// Module ID: 15904
// Function ID: 15905
// Name: useScrollToInitialIndexOnce
// Dependencies: [19, 2]
// Exports: useScrollToInitialIndexOnce
// Module 15904 (useScrollToInitialIndexOnce)
import noop from "module_19" /* 19 */;
const size = fn(2);
const result = size.fileFinishedImporting("modules/collectibles/native/hooks/useScrollToInitialIndexOnce.tsx");
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);
const items = [shouldScroll, initialScrollIndex, num, flashListRef, resetKey];
const effect = noop.useEffect(() => {
if (ref2.current !== resetKey) {
ref2.current = resetKey;
ref.current = false;
}
let tmp2 = null != initialScrollIndex && shouldScroll;
if (tmp2) {
tmp2 = !ref.current;
}
if (tmp2) {
ref.current = true;
const _setTimeout = setTimeout;
const timerId = setTimeout(() => {
const current = ref.current;
if (current != null) {
const obj = { animated: true, index };
current.scrollToIndex(obj);
}
}, num);
}
}, items);
};