Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
render() {
const { snaps } = this.state;
return (
export const updateStateProc = maybeProc((
// custom
value: A.Value,
dest: A.Adaptable,
// state
finished: A.Value,
position: A.Value,
time: A.Value,
frameTime: A.Value,
// config
toValue: A.Value,
) =>
A.block([
A.set(finished, 0),
A.set(time, 0),
A.set(position, value),
A.set(frameTime, 0),
A.set(toValue, dest),
]),
);
0,
// otherwise pre set all the values
[
// If the clock isn't running we reset all the animation params and start the clock
A.set(state.finished, 0),
A.set(state.time, 0),
A.set(state.position, value),
A.set(state.frameTime, 0),
A.set(config.toValue, dest),
A.startClock(clock),
],
),
// we run the step here that is going to update position
A.timing(clock, state, config),
// if the animation is over we stop the clock
A.cond(state.finished, A.block([A.stopClock(clock), onFinish])),
// we made the block return the updated position
A.set(value, state.position),
]);
};
onFinish,
}) => {
const state = {
finished: new A.Value(0),
position: new A.Value(0),
time: new A.Value(0),
frameTime: new A.Value(0),
};
const config = {
duration,
toValue: new A.Value(0),
easing: easing || Easing.inOut(Easing.ease),
};
return A.block([
// stop opposite clock before running our animation
// to set last (previous) position as a current one
oppositeClock
? A.cond(
A.clockRunning(oppositeClock),
A.stopClock(oppositeClock),
)
: 0,
// run our animation clock
A.cond(
A.clockRunning(clock),
// do nothing if our clock is already running
0,
// otherwise pre set all the values
[
// If the clock isn't running we reset all the animation params and start the clock
// reverse input range
// in order to animate value in reverse way
// from `to` to `from`
if (stateValue) {
outputRange.reverse();
}
const valueAnimation = A.interpolate(interpolator, {
inputRange,
outputRange,
extrapolate: A.Extrapolate.CLAMP,
});
animatedBlock.push(valueAnimation);
animationValues[key] = A.block(animatedBlock);
});
acc.backwardAnimations.push(backwardTiming);
return acc;
},
{
forwardAnimations: [],
backwardAnimations: [],
},
);
return A.block([
A.cond(
A.eq(animationState, ANIMATION_STATE.PLAY_FORWARD),
// run all the forward animations
A.block(forwardAnimations),
),
A.cond(
A.eq(animationState, ANIMATION_STATE.PLAY_BACKWARD),
// run all the backward animations
A.block(backwardAnimations),
),
]);
}
{ clock, oppositeClock, value, dest, onFinish }: IAnimationConfig,
props: SpringTweenAnimation,
) => {
const state = {
finished: new A.Value(0),
position: new A.Value(0),
time: new A.Value(0),
velocity: new A.Value(0),
};
const config = {
...transformSpringConfigToAnimatedValues(props.spring),
toValue: dest,
};
return A.block([
// stops opposite (opposite direction) clock
A.cond(
A.clockRunning(oppositeClock),
A.stopClock(oppositeClock),
0,
),
A.cond(A.clockRunning(clock), 0, [
updateStateProc(
value,
dest,
state.finished,
state.position,
state.time,
state.velocity,
config.toValue,
),
dest: to,
};
const backwardAnimationConfig = {
clock: backwardAnimationClock,
oppositeClock: forwardAnimationClock,
value: currentValue,
dest: from,
};
if (first) {
forwardAnimationConfig.onFinish = A.block([
A.set(animationState, ANIMATION_STATE.END_POINT),
]);
backwardAnimationConfig.onFinish = A.block([
A.set(animationState, ANIMATION_STATE.START_POINT),
]);
}
const forwardTiming = getProperAnimation(
config,
forwardAnimationConfig,
);
const backwardTiming = getProperAnimation(
config,
backwardAnimationConfig,
);
acc.forwardAnimations.push(forwardTiming);
acc.backwardAnimations.push(backwardTiming);
render() {
const { delegate } = this.props;
const props = {
...this.props,
onScroll: delegate.event,
onScrollEndDrag: (evt) => this._onScrollEndDrag(evt),
};
return (
this._onScroll(r[0])),
delegate.value,
])}
/>
);
}
}
const updateSwipingNode = useMemo(() => {
if (stackCardAnimationContext) {
return always(
Animated.onChange(stackCardAnimationContext.swiping, [
Animated.call([stackCardAnimationContext.swiping], updateSwiping),
]),
);
} else return Animated.block([]);
}, [stackCardAnimationContext, updateSwiping]);