34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
// Metro module 14107 (f14108).
|
|
import { useRef, useEffect, useState } from "react";
|
|
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
|
|
export default function useIsCarouselInView() {
|
|
let ref3;
|
|
const ref = useRef(null);
|
|
const height = useWindowDimensions_native().height;
|
|
const ref2 = useRef(height);
|
|
useEffect(() => {
|
|
ref2.current = height;
|
|
}, [height]);
|
|
const [isInView, setState] = useState(true);
|
|
ref3 = useRef(isInView);
|
|
useEffect(() => {
|
|
let c27637_0 = setInterval(() => {
|
|
if (ref.current != null) {
|
|
ref.current.measure((a0, a1, a2, a3, a4, a5) => {
|
|
const r19 = Math.max(0, Math.min(a5 + a3, ref2.current) - Math.max(a5, 0));
|
|
const current = a3 > 0 && r19 / a3 >= 0.5;
|
|
if (current !== ref3.current) {
|
|
ref3.current = current;
|
|
setState(current);
|
|
}
|
|
});
|
|
}
|
|
}, 1000);
|
|
return () => clearInterval(c27637_0);
|
|
}, []);
|
|
return {
|
|
containerRef: ref,
|
|
isInView
|
|
};
|
|
};
|