Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default ({ onPress, children, value }: TapHandlerProps) => {
const shouldSpring = new Value(0);
const state = new Value(UNDETERMINED);
const gestureHandler = onGestureEvent({ state });
useCode(
block([
cond(eq(state, BEGAN), set(shouldSpring, 1)),
cond(contains([FAILED, CANCELLED], state), set(shouldSpring, 0)),
onChange(state, cond(eq(state, END), call([], onPress))),
cond(eq(state, END), [delay(set(shouldSpring, 0), duration)]),
cond(
and(eq(shouldSpring, 1), neq(value, 1)),
set(
value,
timing({
from: value,
to: 1,
easing,
duration
})
)
),
cond(
and(eq(shouldSpring, 0), neq(value, 0)),
set(
value,
const config = {
toValue: new Value(0),
...springConfig,
};
return [
cond(clockRunning(clock), 0, [
set(state.finished, 0),
set(state.time, 0),
set(state.velocity, velocity),
set(config.toValue, dest),
set(state.position, value),
cond(
greaterThan(duration, 0),
delay(startClock(clock), delayDuration),
startClock(clock),
),
]),
spring(clock, state, config),
cond(state.finished, stopClock(clock)),
state.position,
];
}
state: state =>
cond(
or(eq(state, State.BEGAN), eq(state, State.END)),
set(this.gestureState, state),
delay(
cond(
or(
neq(state, State.FAILED),
neq(this.panGestureState, State.ACTIVE)
),
set(this.gestureState, state)
),
100
)
),
x: x =>