Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
y,
state
});
const isBack = new Value(0);
const gestureProgress = cond(
isBack,
interpolate(translationX, {
inputRange: [0, width - initialSideWidth],
outputRange: [1, 0]
}),
interpolate(translationX, {
inputRange: [-width, initialSideWidth],
outputRange: [0.4, 0]
})
);
const point = snapPoint(
gestureProgress,
divide(multiply(-1, velocityX), width),
[0, 1]
);
const progress = snapProgress(gestureProgress, state, isBack, point);
const centerY = followPointer(y);
const horRadius = cond(
isBack,
waveHorRadiusBack(progress),
waveHorRadius(progress)
);
const vertRadius = waveVertRadius(progress);
const sWidth = sideWidth(progress);
// useCode(debug("progress", progress), []);
return (
const setIndex = (value: Animated.Node) =>
set(index, modulo(value, length));
useCode(
block([
setIndex(sub(index, increment)),
cond(eq(state, State.BEGAN), [stopClock(clock), set(isActive, 1)]),
cond(eq(state, State.END), [
set(state, State.UNDETERMINED),
set(shouldSnap, 1)
]),
cond(eq(shouldSnap, 1), [
setIndex(
runSpring(
clock,
index,
snapPoint(index, divide(velocityX, -ratio), [
ceil(index),
floor(index)
]),
springConfig
)
),
cond(not(clockRunning(clock)), [set(shouldSnap, 0), set(isActive, 0)])
])
]),
[]
);
return (
);
? [cond(clockRunning(clock), call([springState.position], onSnap))]
: [];
return block([
cond(isSpringInterrupted, finishSpring),
cond(neq(state, State.END), [
set(springState.finished, 0),
set(springState.position, add(offset, value))
]),
cond(eq(state, State.END), [
cond(and(not(clockRunning(clock)), not(springState.finished)), [
set(springState.velocity, velocity),
set(springState.time, 0),
set(
config.toValue,
snapPoint(springState.position, velocity, snapPoints)
),
startClock(clock)
]),
reSpring(clock, springState, config),
cond(springState.finished, [
...snap,
...finishSpring,
set(state, State.UNDETERMINED),
set(value, 0)
])
]),
springState.position
]);
};
)
)
),
set(state.velocity, velocityY),
set(state.time, 0)
],
[
set(translationY, 0),
cond(
and(isInBound, not(isSpringing)),
[decay(clock, state, { deceleration: 0.997 })],
[
set(isSpringing, 1),
set(
config.toValue,
snapPoint(state.position, state.velocity, [
lowerBound,
upperBound
])
),
spring(clock, state, config)
]
)
]
),
state.position
]);
};
const styles = StyleSheet.create({
() => ({
onGestureEvent: gestureEvent({
translationX,
velocityX,
state
}),
translateX: spring(
translationX,
state,
snapPoint(translationX, velocityX, snapPoints)
)
}),
[state, translationX, velocityX]
() => block([
cond(eq(state, State.END), [
set(snapPointX, snapPoint(translationX, velocityX, points)),
set(spring, runSpring(clock, 0, 1)),
cond(
eq(clockRunning(clock), 0),
call([snapPointX], ([x]) => onSnap({ nativeEvent: { x } })),
),
]),
set(
x,
cond(
eq(state, State.ACTIVE),
translationX,
binaryInterpolation(spring, translationX, snapPointX),
),
),
set(
y,