80 lines
3.0 KiB
React
80 lines
3.0 KiB
React
// Metro module 5309 (f5310).
|
|
import Module19, { useContext, useEffect, useMemo, useRef } from "react";
|
|
import { Platform } from "react-native";
|
|
import Module5288 from "./Module5288";
|
|
import { useWebEventHandlers } from "./convertToHandlerTag";
|
|
import { useDetectorUpdater } from "./Module5314";
|
|
import { useViewRefHandler } from "./Module5319";
|
|
import { needsToReattach } from "./Module5315";
|
|
import { useAnimatedGesture } from "./getHandler_5320";
|
|
import { useIsomorphicLayoutEffect } from "./Module5321";
|
|
import Module5299 from "./Module5299";
|
|
import { attachHandlers } from "./Module5317";
|
|
import { dropHandlers } from "./Module5316";
|
|
import { useMountReactions } from "./shouldUpdateDetector";
|
|
import { AnimatedWrap, Wrap } from "./Wrap";
|
|
Platform;
|
|
export const GestureDetector = (a0) => {
|
|
useContext(Module5288);
|
|
if (a0.gesture) {
|
|
let memo, webEventHandlers, current, current2, detectorUpdater;
|
|
const gesture = a0.gesture;
|
|
(function propagateDetectorConfig(a0, a1) {
|
|
for (const item of ["userSelect", "enableContextMenu", "touchAction"]) {
|
|
const r26 = a0[item];
|
|
if (r26 !== void 0) {
|
|
for (const item2 of a1.toGestureArray()) {
|
|
item2.config[item] = r26;
|
|
}
|
|
}
|
|
}
|
|
})(a0, gesture);
|
|
memo = useMemo(() => gesture.toGestureArray(), [gesture]);
|
|
const shouldUseReanimated = memo.some((item) => item.shouldUseReanimated);
|
|
webEventHandlers = useWebEventHandlers();
|
|
current = useRef({
|
|
firstRender: true,
|
|
viewRef: null,
|
|
previousViewTag: -1,
|
|
forceRebuildReanimatedEvent: false
|
|
}).current;
|
|
current2 = Module19.useRef({
|
|
attachedGestures: [],
|
|
animatedEventHandler: null,
|
|
animatedHandlers: null,
|
|
shouldUseReanimated,
|
|
isMounted: false
|
|
}).current;
|
|
detectorUpdater = useDetectorUpdater(current, current2, memo, gesture, webEventHandlers);
|
|
const viewRefHandler = useViewRefHandler(current, detectorUpdater);
|
|
const r58 = current.firstRender || current.forceRebuildReanimatedEvent || needsToReattach(current2, memo);
|
|
current.forceRebuildReanimatedEvent = false;
|
|
useAnimatedGesture(current2, r58);
|
|
useIsomorphicLayoutEffect(() => {
|
|
const viewTag = Module5299(current.viewRef);
|
|
current2.isMounted = true;
|
|
attachHandlers({
|
|
preparedGesture: current2,
|
|
gestureConfig: gesture,
|
|
gesturesToAttach: memo,
|
|
webEventHandlersRef: webEventHandlers,
|
|
viewTag
|
|
});
|
|
return () => {
|
|
current2.isMounted = false;
|
|
dropHandlers(current2);
|
|
};
|
|
}, []);
|
|
useEffect(() => {
|
|
if (current.firstRender) {
|
|
current.firstRender = false;
|
|
} else {
|
|
detectorUpdater();
|
|
}
|
|
}, [a0]);
|
|
useMountReactions(detectorUpdater, current2);
|
|
return shouldUseReanimated ? <AnimatedWrap ref={viewRefHandler} onGestureHandlerEvent={current2.animatedEventHandler}>{a0.children}</AnimatedWrap> : <Wrap ref={viewRefHandler}>{a0.children}</Wrap>;
|
|
}
|
|
throw new Error("GestureDetector must have a gesture prop provided.");
|
|
};
|