166 lines
5.8 KiB
TypeScript
166 lines
5.8 KiB
TypeScript
// Metro module 12320 (f12321).
|
|
import { useCallback, useMemo } from "react";
|
|
import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport";
|
|
import { useSharedValue } from "../../reanimated/ReanimatedRexport";
|
|
import { tryPauseCurrentVideo } from "./useVideoControls";
|
|
import { MediaViewerAnalytics } from "../MediaViewerAnalyticsManager";
|
|
import * as _spring from "../../../design/animation/reanimated/spring/spring";
|
|
import useStableCallback from "../../../hooks/useStableCallback";
|
|
import { Gesture } from "../../../_bundle/Module5273";
|
|
const SPRING_CONFIG = {
|
|
damping: 15,
|
|
mass: 1,
|
|
stiffness: 250,
|
|
overshootClamping: true,
|
|
restSpeedThreshold: 0.001,
|
|
restDisplacementThreshold: 0.001
|
|
};
|
|
const __initData = {
|
|
code: "function useMediaViewerPanGestureTsx1(){const{runOnJS,handleClose}=this.__closure;runOnJS(handleClose)();}"
|
|
};
|
|
const __initData2 = {
|
|
code: "function useMediaViewerPanGestureTsx2(){const{isInteracting,velocity,swipeVelocityThreshold,runOnJS,dismiss,translatePos,withSpring,SPRING_CONFIG}=this.__closure;isInteracting.set(false);const willClose=Math.abs(velocity.get())>swipeVelocityThreshold;if(willClose){runOnJS(dismiss)();}else if(translatePos.get()!==0){translatePos.set(withSpring(0,{velocity:velocity.get(),...SPRING_CONFIG}));}}"
|
|
};
|
|
const __initData3 = {
|
|
code: "function useMediaViewerPanGestureTsx3(_,manager){const{enabled}=this.__closure;if(!enabled.get()){manager.fail();}}"
|
|
};
|
|
const __initData4 = {
|
|
code: "function useMediaViewerPanGestureTsx4({velocityY:velocityY,translationY:translationY}){const{translatePos,start,velocity}=this.__closure;translatePos.set(translationY+start.get().y);velocity.set(velocityY);}"
|
|
};
|
|
const __initData5 = {
|
|
code: "function useMediaViewerPanGestureTsx5(){const{start,translatePos,isInteracting}=this.__closure;start.set({x:0,y:translatePos.get()});isInteracting.set(true);}"
|
|
};
|
|
export function useMediaViewerPanGestureConfig(a0, a1, a2) {
|
|
let callback2;
|
|
const swipeVelocityThreshold = a1;
|
|
const sharedValue = useSharedValue(false);
|
|
const sharedValue2 = useSharedValue(false);
|
|
const sharedValue3 = useSharedValue(0);
|
|
const sharedValue4 = useSharedValue(0);
|
|
const sharedValue5 = useSharedValue({
|
|
y: 0,
|
|
x: 0
|
|
});
|
|
const sharedValue6 = useSharedValue(true);
|
|
const callback = useCallback(() => {
|
|
tryPauseCurrentVideo();
|
|
if (a2 != null) {
|
|
a2();
|
|
}
|
|
MediaViewerAnalytics.markSessionCompleted();
|
|
}, [a2]);
|
|
callback2 = useCallback(() => {
|
|
sharedValue.set(true);
|
|
const r9 = sharedValue4.get() < 0 ? -a0 : a0;
|
|
const r6 = {
|
|
velocity: sharedValue4.get(),
|
|
...SPRING_CONFIG
|
|
};
|
|
const r29 = function t() {
|
|
_ReanimatedRexport.runOnJS(callback)();
|
|
};
|
|
r29.__closure = {
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
handleClose: callback
|
|
};
|
|
r29.__workletHash = 7033730772994;
|
|
r29.__initData = __initData;
|
|
sharedValue3.set(_spring.withSpring(r9, r6, "respect-motion-settings", r29));
|
|
}, [a0, callback, sharedValue, sharedValue3, sharedValue4]);
|
|
return useMemo(() => ({
|
|
velocity: sharedValue4,
|
|
isClosing: sharedValue,
|
|
isInteracting: sharedValue2,
|
|
overlayEnabled: sharedValue6,
|
|
translatePos: sharedValue3,
|
|
swipeVelocityThreshold,
|
|
dismiss: callback2,
|
|
start: sharedValue5
|
|
}), [sharedValue4, sharedValue, sharedValue2, sharedValue3, a1, callback2, sharedValue5, sharedValue6]);
|
|
}
|
|
export function useMediaViewerPanGesture({ swipeVelocityThreshold: swipeVelocityThreshold2, velocity, isInteracting, translatePos, start, dismiss: dismiss2 }, a1) {
|
|
const enabled = a1;
|
|
const dismiss = useStableCallback(dismiss2);
|
|
const callback3 = useCallback(() => {
|
|
const r23 = Gesture.Pan().maxPointers(1).activeOffsetY([-10, 10]).failOffsetX([-10, 10]);
|
|
const V = function V() {
|
|
start.set({
|
|
x: 0,
|
|
y: translatePos.get()
|
|
});
|
|
isInteracting.set(true);
|
|
};
|
|
V.__closure = {
|
|
start,
|
|
translatePos,
|
|
isInteracting
|
|
};
|
|
V.__workletHash = 12024094550213;
|
|
V.__initData = __initData5;
|
|
const r28 = r23.onStart(V);
|
|
const S = function S(a0) {
|
|
const velocityY = a0.velocityY;
|
|
translatePos.set(a0.translationY + start.get().y);
|
|
velocity.set(velocityY);
|
|
};
|
|
S.__closure = {
|
|
translatePos,
|
|
start,
|
|
velocity
|
|
};
|
|
S.__workletHash = 9790035695747;
|
|
S.__initData = __initData4;
|
|
const r35 = r28.onUpdate(S);
|
|
const w = function w(a0, a1) {
|
|
if (!enabled.get()) {
|
|
a1.fail();
|
|
}
|
|
};
|
|
w.__closure = {
|
|
enabled
|
|
};
|
|
w.__workletHash = 10675684732258;
|
|
w.__initData = __initData3;
|
|
const r41 = r35.onTouchesDown(w);
|
|
const r43 = function t() {
|
|
isInteracting.set(false);
|
|
if (Math.abs(velocity.get()) > swipeVelocityThreshold2) {
|
|
_ReanimatedRexport.runOnJS(dismiss)();
|
|
} else if (translatePos.get() !== 0) {
|
|
translatePos.set(_spring.withSpring(0, {
|
|
velocity: velocity.get(),
|
|
...SPRING_CONFIG
|
|
}));
|
|
}
|
|
};
|
|
r43.__closure = {
|
|
isInteracting,
|
|
velocity,
|
|
swipeVelocityThreshold: swipeVelocityThreshold2,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
dismiss,
|
|
translatePos,
|
|
withSpring: _spring.withSpring,
|
|
SPRING_CONFIG
|
|
};
|
|
r43.__workletHash = 3185523772752;
|
|
r43.__initData = __initData2;
|
|
return r41.onEnd(r43);
|
|
}, [dismiss, a1, isInteracting, start, swipeVelocityThreshold2, translatePos, velocity]);
|
|
return useMemo(() => {
|
|
const nativeGesture = Gesture.Native();
|
|
let c27286_0 = nativeGesture;
|
|
let c27286_1 = [];
|
|
return {
|
|
panGestureGenerator: function panGestureGenerator(a0) {
|
|
if (c27286_1[a0] != null) {
|
|
return c27286_1[a0];
|
|
}
|
|
c27286_1[a0] = callback3().blocksExternalGesture(c27286_0);
|
|
return c27286_1[a0];
|
|
},
|
|
nativeGesture
|
|
};
|
|
}, [callback3]);
|
|
}
|