29 lines
915 B
TypeScript
29 lines
915 B
TypeScript
// Metro module 14610 (f14611).
|
|
import { useRef, useEffect } from "react";
|
|
export const INITIAL_SCROLL_DELAY_MS = 100;
|
|
export function useScrollToInitialIndexOnce(a0) {
|
|
const { initialScrollIndex, shouldScroll, flashListRef, afterMs = 100 } = a0;
|
|
let c21252_3 = afterMs;
|
|
const resetKey = a0.resetKey;
|
|
const ref = useRef(false);
|
|
const ref2 = useRef(resetKey);
|
|
useEffect(() => {
|
|
if (ref2.current !== resetKey) {
|
|
ref2.current = resetKey;
|
|
ref.current = false;
|
|
}
|
|
if (initialScrollIndex != null && shouldScroll && !ref.current) {
|
|
ref.current = true;
|
|
setTimeout(() => {
|
|
const current = flashListRef.current;
|
|
if (current != null) {
|
|
current.scrollToIndex({
|
|
animated: true,
|
|
index: initialScrollIndex
|
|
});
|
|
}
|
|
}, c21252_3);
|
|
}
|
|
}, [shouldScroll, initialScrollIndex, afterMs, flashListRef, resetKey]);
|
|
}
|