You're calling "finishAnimation" from the onEnd callback. That could be a problem, since finishAnimation isn't a worklet.
So you have two options:
- finishAnimation can be marked with the "worklet" keyword
const finishAnimation = (swipe_down) => {
"worklet";
// This logger can't be here anymore since it's a JS function
// Logger.bool(swipe_down, { swipe_down });
if (swipe_down) {
offset.value = withTiming(height.value, { duration: 100 }, () =>
runOnJS(props.onSwipeComplete)()
);
} else {
offset.value = withTiming(0, { duration: 200 });
}
};
- finishAnimation can be called async on the JS Thread:
runOnJS(finishAnimation)(
e.velocityY > swipeOutVelocity || offset.value > calculateThreshold()
);
Hopefully it's going to work.