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

50 lines
1.6 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 15021
// Function ID: 15022
2026-07-20 16:05:17 +00:00
// Name: INITIAL_SCROLL_DELAY_MS
2026-07-29 08:29:29 +00:00
// Dependencies: [19, 2]
2026-07-20 16:05:17 +00:00
// Exports: useScrollToInitialIndexOnce
2026-08-24 06:08:38 +00:00
// Module 15021 (INITIAL_SCROLL_DELAY_MS)
import closure_0 from "noop" /* 19 */;
2026-07-23 10:11:24 +00:00
const result = require("set").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;
2026-08-24 06:08:38 +00:00
closure_5 = undefined;
closure_6 = undefined;
2026-07-23 10:11:24 +00:00
closure_5 = initialScrollIndex.useRef(false);
closure_6 = initialScrollIndex.useRef(resetKey);
2026-07-20 16:05:17 +00:00
const items = [shouldScroll, initialScrollIndex, num, flashListRef, resetKey];
2026-07-23 10:11:24 +00:00
const effect = initialScrollIndex.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: null };
2026-08-24 06:08:38 +00:00
obj[1] = closure_0;
2026-07-20 16:05:17 +00:00
current.scrollToIndex(obj);
}
}, num);
}
}, items);
};