mirror of
https://github.com/zoriya/legend-list.git
synced 2026-08-15 18:44:30 +00:00
20 lines
532 B
TypeScript
20 lines
532 B
TypeScript
import { useEffect } from 'react';
|
|
import { Platform } from 'react-native';
|
|
|
|
export function useScrollTest(scrollFn: (offset: number) => void) {
|
|
useEffect(() => {
|
|
let interval: any;
|
|
const timeout = setTimeout(() => {
|
|
let start = 0;
|
|
let inc = 1000;
|
|
interval = setInterval(() => {
|
|
scrollFn((start += inc));
|
|
}, 500);
|
|
}, 1000);
|
|
return () => {
|
|
clearInterval(interval);
|
|
clearTimeout(timeout);
|
|
};
|
|
});
|
|
}
|