47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
// Metro module 14614 (f14615).
|
|
import { createContext, useContext, useRef, useCallback, useMemo } from "react";
|
|
import { NOOP } from "../../../_bundle/Module505";
|
|
const context = createContext({
|
|
registerDismiss: () => NOOP,
|
|
handleDismissCoachmarkOnScroll: void 0
|
|
});
|
|
export function useCollectiblesCoachmarkScrollDismissContext() {
|
|
return useContext(context);
|
|
}
|
|
export function CollectiblesCoachmarkScrollDismissProvider(props) {
|
|
let callback2;
|
|
const children = props.children;
|
|
callback2 = void 0;
|
|
const ref = useRef(null);
|
|
const ref2 = useRef(null);
|
|
const callback = useCallback((a0) => {
|
|
ref.current = a0;
|
|
ref2.current = null;
|
|
return () => {
|
|
if (ref.current === a0) {
|
|
ref.current = null;
|
|
ref2.current = null;
|
|
}
|
|
};
|
|
}, []);
|
|
callback2 = useCallback((a0) => {
|
|
const current = ref.current;
|
|
if (current != null) {
|
|
const contentOffset = a0.nativeEvent.contentOffset;
|
|
if (ref2.current != null) {
|
|
if (Math.abs(contentOffset.x - ref2.current) >= 16) {
|
|
ref.current = null;
|
|
ref2.current = null;
|
|
current();
|
|
}
|
|
} else {
|
|
ref2.current = contentOffset.x;
|
|
}
|
|
}
|
|
}, []);
|
|
return <context.Provider value={useMemo(() => ({
|
|
registerDismiss: callback,
|
|
handleDismissCoachmarkOnScroll: callback2
|
|
}), [callback, callback2])}>{children}</context.Provider>;
|
|
}
|