Transition Properties
Bouncing
Example of how to use Bouncing animation with frame motion.
Bouncing
bouncing.tsx
import Bouncing from '@/components/animations/bouncing' import React from 'react' const Transitions = () => { return ( <div className="p-5"> <Bouncing refresh animate={{start:0, middle:-30, end:0}} transition={{ease:"easeInOut",duration:0.5, repeat: Infinity}}> <div className="w-52 h-52 rounded-full from-orange-500 to-yellow-500 bg-gradient-to-t" /> </Bouncing> </div> ) } export default Transitions "use client" import React, { useState } from 'react' import { Preview } from '../common/display'; import { motion } from "framer-motion"; interface transitionProps{ ease: "anticipate" | "backIn" | "backInOut" | "backOut" | "circIn" | "circInOut" | "circOut" | "easeIn" | "easeInOut" | "easeOut" | "linear"; repeat: number; duration: number; } interface animateProps{ start:number; middle:number end:number; } interface BouncingProps{ children: React.ReactNode; animate: animateProps; transition: transitionProps; refresh:boolean; } const Bouncing = ({children,animate,transition, refresh}:BouncingProps) => { const [count, setCount] = useState(0); return ( <Preview SetCount={setCount} isRefreshing={refresh} animeName='Bouncing'> <motion.div key={count} animate={{ y: [animate.start, animate.middle, animate.end] }} transition={{ ease: transition.ease, repeat: transition.repeat, duration: transition.duration }} > {children} </motion.div> </Preview> ); } export default Bouncing interface PreviewerProps { children: React.ReactNode; SetCount: (count: number) => void; isRefreshing: boolean; animeName:string } export const Preview = ({ children, SetCount, isRefreshing, animeName }: PreviewerProps) => { const [count, setCount] = useState(0); const [isLoading, setIsLoading] = useState(false); const handleClick = () => { setIsLoading(true); setCount(count + 1); SetCount(count + 1); setTimeout(() => { setIsLoading(false); }, 400); // Timeout duration matches the animation duration }; return ( <div className="w-full h-full flex flex-col"> <div className="w-full flex-1 flex justify-center items-center"> {children} </div> {isRefreshing && <div onClick={handleClick} className="h-[50px] w-full px-6 rounded-b-[24px] flex justify-between"> <span>{animeName}</span><RotateCw className={isLoading ? 'animate-spin duration-200' : 'animate-none'} /> </div> } </div> ) };