Complex Animations with Framer Motion & React || useAnimate Hook

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • Animated UI components for React, Tailwind CSS, Framer Motion & More ✨ www.hover.dev
    Framer Motion is my favorite animation library by a long shot (you know that by know if you watch my videos, I won't shut up about it lol).
    That said, using normal motion components has a big downside.
    Orchestrating complex animations is super annoying.
    Fortunately, Framer Motion gives us a SUPER simple hook to fix this problem.
    Today we'll learn how we can leverage the useAnimate hook to build complex, multi-step, multi-element animations with Framer Motion and ReactJS!
    🔗 My Links
    TikTok: / tomisloading
    Instagram: / tomisloading
    GitHub: github.com/Tom...
    Twitter: / tomisloading
    Discord & more: linktr.ee/tomi...
    Portfolio templates: tomisloading.g...
    Website: www.hover.dev

ความคิดเห็น • 65

  • @AaronHongry
    @AaronHongry 5 หลายเดือนก่อน +3

    Your videos are so well-paced while being so informative omg THANK YOU :>

  • @waggadash
    @waggadash 7 วันที่ผ่านมา +1

    Appreciate it! Very well done, thanks Tom :D

  • @naylord5
    @naylord5 ปีที่แล้ว +8

    This looks super cool and with your walkthrough works like a charm.
    Thank you so much for sharing!

    • @tomisloading
      @tomisloading  ปีที่แล้ว

      Happy it helped!! 😁😁

  • @EricMalek
    @EricMalek 10 หลายเดือนก่อน +1

    Thanks for this man! Since I discovered Framer Motion, I prefer it over GSAP. Too many steps to get GSAP to work and if you don't set it up right, it runs through all it's nodes before loading. That's a bad look for a developer...

  • @yajirushik2871
    @yajirushik2871 4 หลายเดือนก่อน +3

    I have wrote many animations with different ways, from transition / keyframes in basic CSS to GSAP and React Transition Group.. but.. the Framer Motion approach with useAnimate in my opinion is the best!

  • @excalibur2417
    @excalibur2417 7 หลายเดือนก่อน +1

    This is exactly what I needed for my project, thank you so much! Liked

  • @akshitagg1
    @akshitagg1 9 หลายเดือนก่อน +2

    hey this(useAnimate hook) is not working if the children are dynamically generated like after fetching from API and then mapping so is there a way to make it work?

  • @rohit_700
    @rohit_700 ปีที่แล้ว +2

    Oh God!
    This just made animating different components so easier....

  • @Siberian-Vladik
    @Siberian-Vladik หลายเดือนก่อน +1

    body, youre a living legend

  • @wingmann3632
    @wingmann3632 5 หลายเดือนก่อน +1

    EXTREMELY COOL TUTORIAL, thank you)

  • @MuhammadAlam-ne9cf
    @MuhammadAlam-ne9cf 8 หลายเดือนก่อน +1

    Tom, I used this to create an animation sequence I have been thinking about for a long time. It worked so perfectly, but when I deployed to prod I realized none of this worked in a mobile browser on my iphone and ipad :( i had to revert back to using a much simpler animation with just motion components with initial/animate/transition props (which worked just fine on iOS chrome and safari browser). Any idea what I might be doing wrong?

    • @MuhammadAlam-ne9cf
      @MuhammadAlam-ne9cf 8 หลายเดือนก่อน +2

      I figured it out: it turns out iphone browsers require SVGs to have an explicitly set width property. working now!

  • @crim-son
    @crim-son 7 หลายเดือนก่อน

    Awesome video🎉🎉, pls is there a way to make offsets between the timelines? Like if you want the toggle button to animate sooner than it should,
    Or how to make two animations run concurrently?

  • @mdrifat6941
    @mdrifat6941 ปีที่แล้ว +2

    O my my.... Again thank you so very much for this video...💝💝

  • @alexbx9
    @alexbx9 5 หลายเดือนก่อน

    I appreciate you making these videos, because you explain things very well. However, I have a question: How can I run two animations simultaneously in an animation sequence and then continue the sequence? Do I skip the await for one of them? Or what is the best way to do this? This is how I did it before.
    const sequence: AnimationSequence = [
    ['.animated__gallery-text', { opacity: 1 }, { duration: 0.8 }],
    ['.galleryt-1', { opacity: 0, maxHeight: 0 }, { duration: 1 }],
    ['.galleryt-2', { opacity: 1 }, { duration: 1 }],
    /*these should play simultaneously*/
    ['.animated__gallery-text', { height: '100px' }, { duration: 1 }],
    ['.galleryt-2', { fontSize: '30px' }, { duration: 1, delay: -1 }],
    /*and this should play after them*/
    ['.galleryt-2', { color: "red" }, { duration: 1}],
    ];
    useEffect(() => {
    animate(sequence);
    }, []);
    So, with your version, it would look like this? Is this correct?
    So, for the animations that I want to run simultaneously, I should remove the await from all of them except the last one, right?
    const handleAnimate = async () => {
    await animate('.animated__gallery-text', { opacity: 1 }, { duration: 0.8 });
    await animate('.galleryt-1', { opacity: 0 }, { duration: 1 });
    await animate('.galleryt-2', { opacity: 1 }, { duration: 1 });
    animate('.animated__gallery-text', { height: '100px' }, { duration: 1 });
    await animate('.galleryt-2', { fontSize: '30px' }, { duration: 1 });
    await animate('.galleryt-2', { rotate: 40 }, { duration: 1 });
    await animate('.galleryt-1', { opacity: 1 }, { duration: 1 });
    };
    useEffect(() => {
    handleAnimate();
    }, []);
    Thank you so much in advance.

  • @temitopedavid9508
    @temitopedavid9508 7 หลายเดือนก่อน +1

    Thanks so much tom🎉

  • @Thomaskbird
    @Thomaskbird 9 หลายเดือนก่อน

    Hey great video, I recently have been experimenting with motion and had the same exact feelings of how complex using motion components can be for very complex animation sequences or where you’d like some animations to be dependent on others. So this useAnimate hook demo is great, but I’m assuming this would only work if all elements that you’d like to animate are within the single component vs a bunch of child components or does that also work?

    • @tomisloading
      @tomisloading  9 หลายเดือนก่อน

      They can absolutely be within child components! 👍 as long as they’re rendered within the scope, they can be animated

  • @goresometimes3528
    @goresometimes3528 7 หลายเดือนก่อน

    How would you incorporate staggerChildren into this and make it so that one set of animations triggers after another? I have these four variants and I'd like the sentence and letter variants to run and then the container and item variants to run after.
    Variants -
    const sentence = {
    hidden: { opacity: 0 },
    visible: {
    opacity: 1,
    transition: {
    delay: 0.2,
    staggerChildren: 0.05,
    },
    },
    };
    const letter = {
    hidden: { opacity: 0 },
    visible: {
    opacity: 1,
    transition: { duration: 0.5, ease: 'easeInOut' },
    },
    };
    const containerVariants = {
    hidden: { opacity: 1 },
    visible: {
    opacity: 1,
    transition: {
    staggerChildren: 0.5,
    },
    },
    };
    const itemVariants = {
    hidden: { opacity: 0 },
    visible: {
    opacity: 1,
    transition: { duration: 2, ease: 'easeInOut' },
    },
    };

  • @mohammad81295
    @mohammad81295 8 หลายเดือนก่อน +1

    Awesome explanation, keep up the quality work

    • @tomisloading
      @tomisloading  8 หลายเดือนก่อน

      Thank you! 😁

  • @ElNicopewpew
    @ElNicopewpew 4 หลายเดือนก่อน

    Great video! Im trying to connect the animation start to scroll but alas, no luck yet!

  • @SuperRockcore
    @SuperRockcore 5 หลายเดือนก่อน +1

    Thanks.. would never be able to figure this stuff out w/o ppl like you..

  • @BooksWeCanRead
    @BooksWeCanRead ปีที่แล้ว +2

    This is awesome! Thanks so much! 👏👏

  • @kurtlee138
    @kurtlee138 9 หลายเดือนก่อน +1

    Amazing stuff, thanks!

  • @FelipeSilvaMedeiros
    @FelipeSilvaMedeiros 10 หลายเดือนก่อน +1

    Great video and explanation. Thanks for share with us.

  • @phuongwj
    @phuongwj 2 หลายเดือนก่อน +1

    BLESS YOU, THANK YOU SO MUCH!!!!!!

  • @fightscene817
    @fightscene817 ปีที่แล้ว +1

    Amazing explanation! Thank you

  • @subhanshusj_jha4978
    @subhanshusj_jha4978 ปีที่แล้ว +1

    Brilliant explanation i am going to Use that in a project

  • @felipefregginrules
    @felipefregginrules หลายเดือนก่อน +1

    This is sooooo good 🎉

  • @tamerahmed9860
    @tamerahmed9860 ปีที่แล้ว +1

    Great tutorial! Thank you 🙏

    • @tomisloading
      @tomisloading  ปีที่แล้ว

      You're very welcome! 😁😁

  • @BasicallyBasics
    @BasicallyBasics 6 หลายเดือนก่อน

    How to set Initial values?
    im trying to make a scale 0 to 1 to the div inside the sceropbut its not animating

  • @duckyshorts89
    @duckyshorts89 2 หลายเดือนก่อน

    Please what's the vs code theme you are using tell me

  • @abimbolapatrick2707
    @abimbolapatrick2707 10 หลายเดือนก่อน

    Do we need to always use a function to trigger the animations?
    How do i trigger series of animation once my page refreshes?

    • @zulhamsy
      @zulhamsy 9 หลายเดือนก่อน

      then call it in useEffect

  • @maduemeka6982
    @maduemeka6982 7 หลายเดือนก่อน +1

    Thank you 💕

  • @michaelrooze278
    @michaelrooze278 10 หลายเดือนก่อน

    Would you have to use forwardRef if passing to a component?

    • @labhamjain3915
      @labhamjain3915 10 หลายเดือนก่อน

      For scope.current i guess

  • @itsdrvgo
    @itsdrvgo ปีที่แล้ว +5

    The way he said, "Hello, this is my face"... I just burst into laughter... XD... Great video btw

  • @bhaveshsaxena9724
    @bhaveshsaxena9724 ปีที่แล้ว +2

    It will be great if you make website using frame motion using multiple components

  • @deepagarwal2504
    @deepagarwal2504 8 หลายเดือนก่อน +1

    Love your face tom, please show it mmore often

  • @אילוןמעיין
    @אילוןמעיין 9 หลายเดือนก่อน +1

    thank you :)

  • @rubenn6160
    @rubenn6160 11 หลายเดือนก่อน

    Wow muy buen video enserio, gracias por explicar este tema bien

  • @taravisser4713
    @taravisser4713 ปีที่แล้ว +1

    Thank you

  • @prashlovessamosa
    @prashlovessamosa ปีที่แล้ว +1

    thanks for sharing

  • @sohrabkhan101
    @sohrabkhan101 8 หลายเดือนก่อน

    How can we define initial state.

  • @developer00007
    @developer00007 11 หลายเดือนก่อน

    Nice!

  • @MDTalha-vt9bi
    @MDTalha-vt9bi 9 หลายเดือนก่อน +1

    i like your code

    • @tomisloading
      @tomisloading  9 หลายเดือนก่อน

      Thank you! :)

  • @gaborlakatos882
    @gaborlakatos882 8 หลายเดือนก่อน

    cool

  • @loground
    @loground 11 หลายเดือนก่อน

    Hey! Did text you in instagram dm and emailed about buying the subscription. Would truly appreciate the response. And thanks for the video again!