Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
const translateX = preserveOffset(translationX, state);
const increment = divide(diff(translateX), ratio);
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 (
export default ({
name,
radius,
isActive,
index,
currentIndex
}: ChannelIconProps) => {
const clock = new Clock();
const value = new Value(0);
useCode(
block([
cond(and(not(isActive), approximates(index, currentIndex)), [
set(value, runSpring(clock, 0, 1)),
cond(not(clockRunning(clock)), set(isActive, 0))
]),
cond(isActive, [stopClock(clock), set(value, 0)])
]),
[]
);
const backgroundColor = interpolateColor(
value,
{
inputRange: [0, 1],
outputRange: [nonActiveColor, activeColor]
},
"rgb"
);
return (
() => 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,
cond(