react-spring

react-spring

需求

  • requestAnimationFrame
  • performance.now

使用

import React from 'react'
import { animated, useSpring } from '@tarojsx/library/dist/react-spring'
const Demo = () => {
const spring = useSpring({
to: async (next, cancel) => {
while (true) {
await next({ opacity: 1, color: '#ffaaee' })
await next({ opacity: 0.5, color: 'rgb(14,26,19)' })
}
},
})
return <animated.View style={spring}>Hello spring</animated.View>
}
03:35Spring
Hello spring