Animating a radial gradient with Framer Motion

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2024

Комментарии • 61

  • @sprioleau
    @sprioleau Год назад +13

    Pro tip: 👍 Like before watching. It's going to be good!

  • @ayoubahabchane
    @ayoubahabchane Год назад +3

    Sam is a gem, as always 💎
    Not only do you learn how to make something work, but the gradual addressing of UX and performance considerations during each iteration gives you unshakeable confidence in the code you're writing.

  • @lokkeestudios
    @lokkeestudios Год назад +3

    Been using these sort of card spotlight effects for quite a while now. Nice to see a different approach to them.
    Keep up the neat, high-quality content! 🎉

  • @DioArsya
    @DioArsya Год назад

    Framer should sponsored you for all hi quality contents on framer motion, love it!

  • @fiordnord
    @fiordnord Год назад

    I just love Jamie Lanister teaching me front end

    • @samselikoff
      @samselikoff  Год назад +1

      LOL going through the show now for the first time... this is either an insult or compliment depending on if we're talking season 1 jamie or season 3 😂

    • @fiordnord
      @fiordnord Год назад

      @@samselikoff Definitely the compliment! Only based on visual resemblance😄

  • @halmic
    @halmic Год назад

    Crazy thanks for the tip to use groups for the detection- I was initially going to use another motionvalue, but the group idea keeping it in-css is much neater.

  • @jeffsegovia00
    @jeffsegovia00 Год назад

    We don't deserve this tutorial. Thanks Sam. I learned a lot... Again... Please keep it coming! ☺

  • @jordan_777.
    @jordan_777. Год назад

    Beautiful man. I saw you talking about your course the other day and was like "yeah I'm getting it". Saw the price and changed tune real fast. The thing is, after binge watching your videos, I'm beginning to see that most likely no one is going to be able to give me that same knowledge and experience. Gonna have to get that course very soon!
    Thanks for the amazing videos!

  • @MrUltimateX
    @MrUltimateX Год назад +3

    Sam can you please make a video of how you have your VSCode setup? And what power-user shortcuts and tools you use? It always so satisfying to see you navigate and use VSCode so well

    • @kemplerart9707
      @kemplerart9707 Год назад

      For navigation, I think he uses the Vim plugin.

  • @zyzlol
    @zyzlol Год назад

    hey that gradient position option is awesome

  • @benshapiro9731
    @benshapiro9731 Год назад

    absolute god-tier video, hats off sir

  • @FlorinPop
    @FlorinPop Год назад +1

    Loved it!! ❤
    Recreated it in Vanilla and then in React also (no framer)

    • @ammargillani509
      @ammargillani509 Год назад

      Would love to see a video on a vanilla version of this Florin. Great video Sam!!

  • @igrb
    @igrb Год назад

    you just keep on posting bangers. Love it!

  • @DEV_XO
    @DEV_XO Год назад

    🔥More framer motion content please!

  • @Benjamin-Chavez
    @Benjamin-Chavez Год назад

    Incredible vids. Thank you!!

  • @rand0mtv660
    @rand0mtv660 Год назад +2

    I hope React introduces some primitives to make animations a first class citizen in React. It's funny that in order to get good performance, you essentially have to do things outside of React. I've seen React maintainers mention that they want to make animation primitives for React, but I'm guessing that's still far into the future considering server components are currently the main focus as far as I've seen.

  • @spiritz0r317
    @spiritz0r317 Год назад +2

    Such a great video and effect. Unfortunately RUclips's compression doesn't do it justice. You should consider publishing your videos in 4k too. Keep up the great work!

    • @samselikoff
      @samselikoff  Год назад +4

      Great idea - I was wondering about how to fix that. Will be experimenting on this soon!

  • @hampusnilsson2389
    @hampusnilsson2389 Год назад

    Love your videos! Would love to see this example with a smoothed out animation using lerp and Framer Motion! So the gradient “lags” behind the cursor a bit :)

  • @wfl-junior
    @wfl-junior Год назад

    awesome effect

  • @dvlden
    @dvlden Год назад +1

    I see you combine some basic CSS transitions and Framer Motion. What do you think of using only one or the other? E.g. only CSS or only Framer Motion. Any pros and cons you could point out?

  • @FishTalkFish
    @FishTalkFish Год назад

    Great video, Sam! Thumbs up!

  • @fam0uq
    @fam0uq Год назад +2

    Hey Sam, nice video and good introduction for Framer-motion!
    But you can do this easily without any animation library, just use ref instead (as libraries do under the hood).
    So code will be like this
    ```
    function handleMouseMove(e: MouseEvent) {
    const { left, top } = e.currentTarget.getBoundingClientRect();
    const mouseX = e.clientX - left;
    const mouseY = e.clientY - top;
    gradientRef.current?.style.setProperty(
    "background",
    `radial-gradient(
    650px circle at ${mouseX}px ${mouseY}px,
    rgba(14, 165, 233, 0.15),
    transparent 80%
    )
    `
    );
    }
    ```
    p.s don't forget add ref to gradient div

    • @samselikoff
      @samselikoff  Год назад +1

      I prefer having one approach to all techniques like this since (a) it saves energy from having to think about multiple approaches and (b) more importantly, composes with any new functionality I might want to add. For example I made a version of this that used a useMeasure() hook to update the circle width, x, and y positions based on window resizes. Because the Framer Motion version is in the render function all of that new functionality just worked. In your version, you'd have to refactor the imperative `setProperty` call back out into render.
      In general my rule is to use the declarative version of any API as a first pass since by default it's reactive, and to only dip into imperative APIs when they're necessary.

    • @muhammadrashid7724
      @muhammadrashid7724 Год назад

      @@samselikoff nice explanation.

  • @jacobkim9856
    @jacobkim9856 Год назад

    Glorious video

  • @maxwell_young
    @maxwell_young Год назад

    love this tutorial as i do all your work, was following along but got stuck with useMotionTemplate not fixing the "Rendered more hooks than during the previous render." error. Just curious if you know any reason this hook from framer motion might not have worked correctly in this instance.

    • @samselikoff
      @samselikoff  Год назад

      thank you! that should just happen once, because here I put the hook directly in the render body, so the first time you save because of hot refresh, you're adding a hook that wasn't there the previous render. you can always move the hook up and set the return value in a variable, and then use that in the JSX, if it's causing you problems (for example due to any conditional rendering in your template).

  • @maxwebstudio
    @maxwebstudio Год назад +1

    You and @ThePrimeagen, inspired me give Vim a try,
    I installed the Intellij's IdeamVim plugin.....
    ☠ First two were hard... I really struggled...
    🔥 But I must admit after 5 days now.... There is no going back !!! 🚀
    So thank you so much for the good content and the inspiration 💪

    • @redaaaa
      @redaaaa Год назад +1

      He's using vscode...

    • @heyiamigor
      @heyiamigor Год назад

      @@redaaaa with Vim plugin

    • @maxwebstudio
      @maxwebstudio Год назад

      ​@@redaaaa Yes I know :) But I'm using PhpStorm. 😊

  • @ER1C897
    @ER1C897 Год назад +1

    Hey Sam, wondering what you use for the automatic string interpolation at 8:35? Namely just it automatically switch from " to ` after the ${} input? This would save me literal seconds!

    • @abe10
      @abe10 Год назад

      Template String Coverter

  • @faridhamzayev8082
    @faridhamzayev8082 Год назад

    Great animation! I'm wondering if the animation would still work if you changed react useState with useRef and update ref values instead?

  • @zakioria7478
    @zakioria7478 Год назад

    Always impressed by your videos, Keep it up!

  • @ereburg
    @ereburg Год назад

    Awesome tutorial, thank you!
    Wondering, is it possible to create scroll-spy functionality with framer-motion?

  • @BinhNguyen-os1dc
    @BinhNguyen-os1dc Год назад

    love your content so much ❤

  • @kristemmerman921
    @kristemmerman921 Год назад

    Great video Sam!

  • @YuraZavadenko
    @YuraZavadenko Год назад

    great as per usual

  • @ZachSchnackel
    @ZachSchnackel Год назад

    Classic Ugmonk shirt 😎

  • @bhatvikrant
    @bhatvikrant Год назад

    What extension do you use in VScode to turn quotes into template strings automatically Sam?

  • @mukleshossen751
    @mukleshossen751 Год назад

    Really impressed brother 😍

  • @alterickoo
    @alterickoo Год назад

    Great Video!!

  • @isneru
    @isneru Год назад

    Hey Sam, Framer-motion's lib seems so extensive, how do you find all these new hooks/functions? Do you just explore the docs?

  • @هاديمحمد-و8ظ
    @هاديمحمد-و8ظ Год назад

    Big like 👌 👍 😗. Thank you...

  • @jafetl.ch.8961
    @jafetl.ch.8961 Год назад

    What Headwind config do you use? I saw when you wrote `group` in the parent div (14:53), automatically the group change position in class name
    pd: I love your content!

  • @EvertJunior
    @EvertJunior Год назад

    Amazing as always! On a side note, are you using the oficial Dracula theme on vscode or is it some variant? It looks darker and nicer.

  • @icaro_rdp
    @icaro_rdp Год назад

    NEAT !

  • @yolla_4
    @yolla_4 Год назад

    hey Sam what extension your'e using for tailwind class auto alignment on save

  • @rishigupta3739
    @rishigupta3739 Год назад

    Just one question to you Sam is it good to copy your code and it into our portfolio?

  • @sillyleo
    @sillyleo Год назад

    Awesomeness 🎉

  • @rizwansabir2448
    @rizwansabir2448 4 месяца назад

    I realized that u should have used offsetX and offsetY to find the center and your video can be shorter too.😅

  • @bullettime2808
    @bullettime2808 Год назад

    damnn

  • @mukleshossen751
    @mukleshossen751 Год назад

    1st view 🙃