Framer Motion Animate When In View

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

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

  • @DEVAMS01
    @DEVAMS01  ปีที่แล้ว +3

    Hey there, my awesome brothers and sisters!
    I've given the channel a little shake-up. Back in July 2023, I decided to quit my programming job.
    If you're curious about what led to this change, check out this video: th-cam.com/video/QTUiDhttX18/w-d-xo.htmlsi=gJQ-7b5Ryyyp6tdb.
    With that said, I'm currently creating more 'self-development/improvement' kind of content. If your interest has been sparked, you can find it right here: www.youtube.com/@DEVAMS01/videos.
    If not keep enjoying the tutorial :D.
    Cheers, Björn

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

    BRO this took me days to learn and you explained it in 15 min 🙇🏻‍♂

  • @adrianbradu7824
    @adrianbradu7824 3 ปีที่แล้ว +18

    I've read and watched several articles/videos on this topic and so far the conclusion is that your way of explaining it is so "graspy". Great job!

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

    i just watched this video in 2023 and i inferred that you're the king of animations ❤❤

  • @thecutedreamkostasp.4449
    @thecutedreamkostasp.4449 2 ปีที่แล้ว

    Duuude u so good on explaning!!! Also u seem so happy after using react magic haha! Ty for tutorial!

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

    now you don't need to intstall thrid party hooks you can use whileInView like this :

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

    Literally THE best intro ever, had me in stitches 🤣. Cheers for the excellent tutorial mate, helped a lot.

  • @VskiDevs
    @VskiDevs 2 ปีที่แล้ว

    man I like this guy😂 from the moment he slid in with his chair, i knew this was gonna be fun. Thanks for the video

    • @DEVAMS01
      @DEVAMS01  2 ปีที่แล้ว

      Haha thanks man!! 😂😀

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

    still relevant in 2023. You're the bomb!

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

      haha thank you!

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

    You are clearer than the official docs 😊. Implemented and works, thanks alot!

    • @DEVAMS01
      @DEVAMS01  2 ปีที่แล้ว

      haha thanks mate! Good to hear!

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

    bro u made my day, i have been searching for it and AI give this video. im going to try now

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

      haha good to hear bro! 👊

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

    amzazing tutorial. thank you so much....I'm watching you from Africa

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

    Bonjour DEVAMS, merci beaucoup pour cette belle vidéo!

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

      haha thanks man!! 😁

  • @Sameer.Trivedi
    @Sameer.Trivedi ปีที่แล้ว

    You are so talented man. Your videos help so much

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

      Thanks man!! Im very happy that they are helping 😄. And really appreciate your kind words!

  • @shawnsu9155
    @shawnsu9155 2 ปีที่แล้ว

    OMG, you are fantastic, and totally saved my bacon! Thanks for the video!

  • @norge_indiankumar2264
    @norge_indiankumar2264 2 ปีที่แล้ว

    holy shit.. this guy is a legend

  • @monirhossainrabby7259
    @monirhossainrabby7259 2 ปีที่แล้ว

    Great explanation brother👍❤️

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

    Thank you! I was looking exactly for this!

  • @NamNguyen-oz8uj
    @NamNguyen-oz8uj 3 ปีที่แล้ว

    Best tutorial about Framer-motion. I'm stuck in my project trying to use Framer-motion, this helps a lot. Thank you very much! 🙏🙏🎉🎉😁😁

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

    This was an awesome video! You deserve more subs

  • @53Strat
    @53Strat 2 ปีที่แล้ว

    DIt was het laatste onderdeel wat ik heb bekeken. Helle toffe series. Heb ervan genoten en dit heeft echt bijgedragen aan mijn algemene begrip na het volgen van uitgebreide React tutorials. Denk dat ik hierna wel een echte poging aandurf voor een uitgebreide functionele portfolio. Hartstikke bedankt!

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

    Thanks for this tutorials, I'm learning a lot with your explanations

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

      Thank you!!

  • @devashish-soni
    @devashish-soni ปีที่แล้ว

    Helped a lot! Very easy to understand and apply, Thanks! 👍👌

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

      Thanks man, very nice to hear! Keep going!🦾

  • @kinglycodes
    @kinglycodes 3 ปีที่แล้ว +9

    Great explanation. Exactly what I needed. Thank you so much. :)

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

    Thanks bro, your explanation was clear

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

      Good to hear bro!🦾

  • @arthur1387
    @arthur1387 2 ปีที่แล้ว

    Best Explanation I've come across so far. . Thanks so much for this! looking forward to more tutorials. subscribed

  • @yagovelazquez9140
    @yagovelazquez9140 2 ปีที่แล้ว

    Good job brother!

  • @Jesus-xp6cf
    @Jesus-xp6cf 2 ปีที่แล้ว +1

    Great explanation bro. Thank you for teaching us new developers. Really appreciated

  • @Lee-sy7pc
    @Lee-sy7pc 2 ปีที่แล้ว +1

    This video is so useful to me ! thanks DEVAMS :)

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

    Thank you so much . Really Apreciated !

  • @eshw23
    @eshw23 2 ปีที่แล้ว

    insanely helpful added this to my project!!

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

    Ahhh I found this so helpful, thank you.

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

    your video helped me a lot! thank you so much!

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

      Nice man! 🦾

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

    Good video but what about when i have slightly different starting position or delay for each element ? What you did assumes all cards will have the same animation

  • @chandarayi212
    @chandarayi212 2 ปีที่แล้ว

    Glad that you made this possible for us

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

    hey nice walk through. by the way the animation works only when targeted to one div or something.
    can you explain how it can be extended to another div

  • @simranbanwait
    @simranbanwait 2 ปีที่แล้ว

    Great video bro , thankyou so much

  • @tuanvo3171
    @tuanvo3171 2 ปีที่แล้ว

    Great video

  • @DieghoxCr7
    @DieghoxCr7 2 ปีที่แล้ว

    Excellent, thanks

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

    You saved my day 🤜🤛

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

      Haha nice to hear man! 😁

  • @pubggamingnepal1157
    @pubggamingnepal1157 3 ปีที่แล้ว

    loved your video man

  • @maskman4821
    @maskman4821 3 ปีที่แล้ว

    This is an awesome framer motion tutorial !!! 🤩🤩🤩

    • @DEVAMS01
      @DEVAMS01  3 ปีที่แล้ว

      Thank you so much!! I'm glad you enjoyed it! 😁

  • @muzammilsyed2339
    @muzammilsyed2339 3 ปีที่แล้ว

    Great video lad.

  • @krishnadhingra2723
    @krishnadhingra2723 2 ปีที่แล้ว

    Loved the video :)

  • @borisaleksandrovskiy1962
    @borisaleksandrovskiy1962 3 ปีที่แล้ว

    Great video, man!

  • @shakthinaarayananr7639
    @shakthinaarayananr7639 2 ปีที่แล้ว

    Hey we can directly add conditional operator && or ?: in the varients like opacity: isView ? 1 : 0, scale: isView ? 1 : 0,

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

    Thank you so much brother, you are the best 🌟🌟

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

      Thanks bro! 😁

  • @mofe620
    @mofe620 2 ปีที่แล้ว

    This is amazing. Thank you so much

  • @eskimo6097
    @eskimo6097 3 ปีที่แล้ว

    Awesome explanation, thank you!!

  • @bodomow
    @bodomow 3 ปีที่แล้ว

    I love your explanation, great video! c:

  • @antrikshsingh2503
    @antrikshsingh2503 3 ปีที่แล้ว

    exactly what i wanted THANKS!!!!

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

    Thank you so much for this great tutorial ❤️

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

      Thanks man!!

  • @shrikantjha5630
    @shrikantjha5630 2 ปีที่แล้ว

    Good job

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

    Thanks! Great info here ✌️

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

      Thank you! 👊

  • @leenardlacay3422
    @leenardlacay3422 2 ปีที่แล้ว

    Very nice video man, just wondering you can put the ref in the motion.div right? That'll make it more sync?

  • @clipsbyczar
    @clipsbyczar 2 ปีที่แล้ว

    amazing video

    • @DEVAMS01
      @DEVAMS01  2 ปีที่แล้ว

      Thanks!!

  • @frz_akbar
    @frz_akbar 3 ปีที่แล้ว

    wonderful tutorials

  • @erkikadhafi9155
    @erkikadhafi9155 2 ปีที่แล้ว

    Thanks man, helps alot

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

    Very good and funny too!

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

      Thanks man!

  • @mishanep
    @mishanep 3 ปีที่แล้ว

    Nice job, man! Thank you!

  • @yash7241
    @yash7241 3 ปีที่แล้ว

    Thanks a lot , this was very helpful

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

    very helpful video, thanks

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

      Thank you!

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

    Haha smooth intro, mate. Another nice video. You could consider adding the animation to the child elements instead of the parent, so that the element fly in one-by-one when scrolling down the page.

    • @DEVAMS01
      @DEVAMS01  3 ปีที่แล้ว

      Glad you liked the intro bro haha. Good suggestion about the animation! I'll have a look into that!

    • @abbaadamu3927
      @abbaadamu3927 3 ปีที่แล้ว

      how please

  • @adam67bree
    @adam67bree 3 ปีที่แล้ว

    Great tutorial thanks

  • @rafaelangelopiad8919
    @rafaelangelopiad8919 2 ปีที่แล้ว

    Thank you!

  • @caolanfanning7261
    @caolanfanning7261 3 ปีที่แล้ว

    awesome video!!! subscribed for sure!

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

    wonderful thank you

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

    Thank you🙏

  • @TurpoChargedGaming
    @TurpoChargedGaming 2 ปีที่แล้ว

    How would i use `ref={ref}` with multiple elements on the same page?

  • @reactdevs7867
    @reactdevs7867 2 ปีที่แล้ว

    Thank you so much

  • @designcoded7585
    @designcoded7585 3 ปีที่แล้ว

    sir can you tell whats the difference between path spacing , path offset
    in framer motion what the exact use of it in svg animation

  • @paulopma
    @paulopma 3 ปีที่แล้ว

    Thanks man, you helped a lot

  • @vai592
    @vai592 3 ปีที่แล้ว

    Great video, but quick question. Why mess around with the threshold and not just apply the ref directly to the div containing the movies?

    • @norge_indiankumar2264
      @norge_indiankumar2264 2 ปีที่แล้ว

      i think it has to do with the fact that those divs may not trigger animations properly , when zoomed in or the div has a lot of empty space or something.. react gods must have thought of that

  • @mante0520
    @mante0520 2 ปีที่แล้ว

    Thanks for the Tutorial, really well done and helpful.
    Altough i have some trouble monitoring a secon ref, since react only allows the name ref for as a name for the reference.
    Does anyone have a solution to that problem ?

  • @dimtodim
    @dimtodim 3 ปีที่แล้ว

    great tut

  • @robin9436
    @robin9436 3 ปีที่แล้ว

    Awesome, thank you!

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

    Idk if it's been added recently but, there's a useInView hook that's built-in to Framer Motion. Great tutorial though!

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

      I think whileInView fixes this problem.

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

      @@thejustprojects oh that's cool, I'll give it a try 👍

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

    i am getting this eror :( - TypeError: Cannot read properties of undefined (reading 'current')

  • @prabhurao2773
    @prabhurao2773 2 ปีที่แล้ว

    hey , im having some poblem with framer motion , the website goes laggy or frames drops!! is there a way to handle the frame drops ? i get this message on the client side console saying , animation took 137ms to complete and its looks so choppy can you explain why this is happening. ?

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

    how to animate scrolling up ?

  • @prabhurao2773
    @prabhurao2773 2 ปีที่แล้ว

    i have saved your video (no offence) i have liked the video , i have subscribed the channel and i have shared it to my many other developer friends and as a bonus i am subscribing from 4 other devices !! ---- > `${ also i love the entry }`

  • @shinkobayashi5915
    @shinkobayashi5915 3 ปีที่แล้ว

    Thank you for the video. How do you organise your code when there are many animations on the page? Do you initialise many useAnimation() ?

    • @clementgombauld8262
      @clementgombauld8262 2 ปีที่แล้ว

      You just build a custom hook to reuse the logic every time you need it

  • @rafayzia4180
    @rafayzia4180 2 ปีที่แล้ว

    thanks alot man!

  • @partharoy1733
    @partharoy1733 3 ปีที่แล้ว

    As usual great tutorial. How animate only for the first time while scrolling down. Please help.

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

    whileInview insted of all of that steps see framer motion doc and tell me your opinion please ?

    • @MrSaaul
      @MrSaaul 2 ปีที่แล้ว

      To also fix the issue on 13:43 you can set the margin in the viewport to prevent the animation from happening right away
      viewport={{
      once: true,
      margin: "-240px"
      }}

  • @ahmedghonim7062
    @ahmedghonim7062 3 ปีที่แล้ว

    thanks soooooooooo mush you make it easy

  • @horacinis
    @horacinis 3 ปีที่แล้ว

    Great video! Thank you so much :)

  • @yaserdemet7886
    @yaserdemet7886 2 ปีที่แล้ว

    If some1 ask for Framer Motion's documentation, i ll show u. Much obliged !

  • @8koi245
    @8koi245 ปีที่แล้ว

    I was looking for this yesterday lmao, but found the intersection library

  • @ilkinibadov1397
    @ilkinibadov1397 2 ปีที่แล้ว

    Hi, Thank you for super clear explanation. One question I have is how did you write your Routes so they all render continuously in one page? Whenever I try to define a Route for each component, only that component renders on the screen (changes via link ending). Can I take a look at the component that has the Routes in it?

    • @suhasrao4324
      @suhasrao4324 2 ปีที่แล้ว

      He didnt use react-router. Just anchor elements combined with html id. You can see that in his navlinks components

  • @kodraa
    @kodraa 2 ปีที่แล้ว

    this only worked for me when x was set to -95vw instead of -100vw, please help

  • @dexkode5558
    @dexkode5558 3 ปีที่แล้ว

    incredible explanation, what if I want to observe multiple div ?

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

      Use InView Component from react-intersection-observer and wrap motion.div with {({ref,inView})=>(.........)}. Now you can you use it for any container.. Just wrap with InView Component and give ref

  • @stormz2385
    @stormz2385 3 ปีที่แล้ว

    thanks a ton!

  • @phantazzor
    @phantazzor 2 ปีที่แล้ว

    would have been nice to do it for each item

  • @jordanlugenbeel2110
    @jordanlugenbeel2110 3 ปีที่แล้ว

    This works great on only one div. How can you do this with different divs and with different animations?

    • @nowaccki
      @nowaccki 3 ปีที่แล้ว

      within your component, for example:
      const myvariants = {
      hidden: {..enter parameters here..},
      show: {..enter parameters here..}
      }
      the ternary operation in animate={ } basically just sets the variant to show if inView is true, and hidden if inView is false. You should check out the framer motion discord if you need any more help though!

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

      You could just create a custom hook that implements the same logic.
      /**
      * useCustomAnimation.js File
      */
      // React
      import { useEffect } from "react";
      // Animation & Motions
      import { useAnimation } from "framer-motion";
      import { useInView } from "react-intersection-observer";
      /**
      * This is a custom hook to toggle a Framer Motion animation
      * when an element is in view or out of view
      *
      * @param {object} start - the framer motion animation object when IN view
      * @param {object} end - the framer motion animation object when OUT of view
      * @param {number} threshold - the threshold for when IN view
      * @returns {object} an object with the ref and the animation
      */
      const useCustomAnimation = (start, end, threshold = 0.25) => {
      const animation = useAnimation();
      const { ref, inView } = useInView({ threshold });
      /**
      * This effect toggles when the animation is
      * in view. When in view, the start variable
      * is animated and when out of view the end
      * variable is used to animate.
      */
      useEffect(() => {
      if (inView) animation.start(start);
      else animation.start(end);
      }, [inView, animation, start, end]);
      return { ref, animation };
      };
      export default useCustomAnimation;
      /**
      *Your React Component File
      */
      // Import your motion & custom hook
      import { motion } from "framer-motion";
      import useCustomAnimation from "../../../../../hooks/useCustomAnimation";
      // Define your animation params
      const start = {
      x: 0,
      transition: {
      type: "spring",
      duration: 1,
      bounce: 0.3,
      },
      };
      const end = { x: "-100vw" };
      // Call the hooks
      const divOneAnimation = useCustomAnimation(start, end, );
      const divTwoAnimation = useCustomAnimation(start, end, );
      {}
      {}
      Hope this helps..

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

    why couldn't you just add the ref attribute to a diffrent div/tag

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

    Why not just use 'whileInView' and 'viewport' props available in framer-motion itself!

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

    Just used this and modified to use the framer motion useInView hook, and it merged seamlessly. Great video!

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

    I did this its working but framer motion implemented new method : whileInView="visible" just add as attribute guys

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

    Thank you so much for your videos, you really saved my projects and i learned so much! Could You please make a video of how to make the navbar that you created into a hamburger bar.

    • @DEVAMS01
      @DEVAMS01  3 ปีที่แล้ว

      Thank you very much! I'll try to record that video upcoming weekend!

    • @DEVAMS01
      @DEVAMS01  3 ปีที่แล้ว

      th-cam.com/video/Et5tDPoU03c/w-d-xo.html