在这段代码中,react-spring
我得到了一个动画,其中每个字母都等到前一个动画结束,同时它正在被动画化
为什么会发生这种情况,我该如何解决?
const text = [...'hey there how are you']
const from = { transform: 'rotateX(0deg) translateY(0px) rotate(0deg) scale(1)' }
const to = inView
? [
{ transform: 'rotateX(30deg) translateY(10px) rotate(-13deg) scale(1)' },
{ transform: 'rotateX(0deg) translateY(-22px) rotate(3deg) scale(1.1)' },
{ ...from },
]
: from
const trail = useTrail(text.length, {
config: { mass: 5, tension: 2000, friction: 200 },
from: from,
to: to,
})
return (
<>
<Div ref={handleRef}>
{trail.map((props, i) => (
<animated.span key={`char${i}`} style={props}>
{text[i] === ' ' ? <> </> : text[i]}
</animated.span>
))}
</Div>
</>
)