animation

Basic usage

import {Animate} from "tuix-design"
copy
<Animate
animate={["bg:red", "bg:orange", "bg:green"]}
option={{ iterations: Infinity, duration: 2000 }}
>
<Icon name="Home" color="#ffffff" />
</Animate>
copy

Manual animation

In some cases animation need to be handle manually. Use ref to access the handler function

const ExampleAnimation = ()=>{
const animation = useRef<any>(null);

return (
    <div>  
        <Animate 
                ref={animation} 
                animate={["bg:red", "bg:orange", "bg:green"]} 
                option={{ iterations: Infinity, duration: 2000 }} 
                auto={false}
                >
            <Icon name="Home" color="#ffffff" />
        </Animate>
        <Flex gap={5}>
            <Button onClick={() => animation.current.play()} variant="secondary">
                play
            </Button>
            <Button onClick={() => animation.current.pause()} variant="secondary">
                pause
            </Button>
            <Button
                onClick={() => animation.current.reverse()}
                variant="secondary"
            >
                reverse
            </Button>
            <Button onClick={() => animation.current.stop()} variant="secondary">
                stop
            </Button>
        </Flex>
    </div>
)
}
copy

API

propstypestatusdefaultdescription
animatestyleProperties[]requiredNoneanimation keyframe
optionoptionPropertiesoptionaldefaultOptionPropertiesanimation option
autobooleanoptionaltruetrue if animation start automatically

Option Properties

propstypestatusdefaultdescription
delaynumberoptional0animation delay in millisecondes
durationnumberoptional500animation duration in millisecondes
iterationsnumberoptional1animation iterations
easingease | linear | ease-in | ease-out | ease-in-out | step-start | step-endoptionallinearanimation easing
basicmanualapioption properties