useTime
useTime
返回一个motion 值它每帧更新一次,包含自创建以来经过的时间,单位为毫秒。
这在生成永久动画时特别有用。
const time = useTime(); const rotate = useTransform(time, [0, 4000], [0, 360], { clamp: false }); return <motion.div style={{ rotate }} />
用法
从 Motion 导入
import { useTime } from "motion/react"
当调用 useTime
时,它会创建一个新的 motion 值。该值将每帧更新,包含自其创建以来的时间。
你可以直接使用它,或者与其他 motion 值 Hook 组合使用。
const time = useTime() const rotate = useTransform( time, [0, 4000], // For every 4 seconds... [0, 360], // ...rotate 360deg { clamp: false } )
useTime
返回一个motion 值它每帧更新一次,包含自创建以来经过的时间,单位为毫秒。
这在生成永久动画时特别有用。
const time = useTime(); const rotate = useTransform(time, [0, 4000], [0, 360], { clamp: false }); return <motion.div style={{ rotate }} />
用法
从 Motion 导入
import { useTime } from "motion/react"
当调用 useTime
时,它会创建一个新的 motion 值。该值将每帧更新,包含自其创建以来的时间。
你可以直接使用它,或者与其他 motion 值 Hook 组合使用。
const time = useTime() const rotate = useTransform( time, [0, 4000], // For every 4 seconds... [0, 360], // ...rotate 360deg { clamp: false } )
useTime
返回一个motion 值它每帧更新一次,包含自创建以来经过的时间,单位为毫秒。
这在生成永久动画时特别有用。
const time = useTime(); const rotate = useTransform(time, [0, 4000], [0, 360], { clamp: false }); return <motion.div style={{ rotate }} />
用法
从 Motion 导入
import { useTime } from "motion/react"
当调用 useTime
时,它会创建一个新的 motion 值。该值将每帧更新,包含自其创建以来的时间。
你可以直接使用它,或者与其他 motion 值 Hook 组合使用。
const time = useTime() const rotate = useTransform( time, [0, 4000], // For every 4 seconds... [0, 360], // ...rotate 360deg { clamp: false } )