Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
animatePopoverToLayout(layout: Forto.Calculation) {
Popmotion.spring({
from: this.popoverReaction.get(),
to: { ...layout.popover, opacity: 1 },
velocity: this.popoverReaction.getVelocity(),
stiffness: 450,
damping: 35,
mass: 1.5,
}).start(this.popoverReaction)
}
listen(document, 'mouseup touchend').start(() => {
spring({
from: this.ballXY.get(),
velocity: this.ballXY.getVelocity(),
to: { x: 0, y: 0 },
stiffness: 200
}).start(this.ballXY);
});
};
return value.attach((v, set) => {
if (activeSpringAnimation.current) {
activeSpringAnimation.current.stop()
}
activeSpringAnimation.current = spring({
from: value.get(),
to: v,
velocity: value.getVelocity(),
...config,
}).start(set)
return value.get()
})
}, Object.values(config))
const checkBounce = () => {
if (!isFalling || ballY.get() < 0) return;
isFalling = false;
const impactVelocity = ballY.getVelocity();
const compression = spring({
to: 1,
from: 1,
velocity: -impactVelocity * 0.01,
stiffness: 800
})
.pipe(s => {
if (s >= 1) {
s = 1;
compression.stop();
if (impactVelocity > 20) {
isFalling = true;
gravity.set(0).setVelocity(-impactVelocity * 0.5);
}
}
return s;