No video

Horizontal Scrolling Animation with React and Framer Motion

  Рет қаралды 56,570

Tom Is Loading

Tom Is Loading

11 ай бұрын

Animated UI components for React, Tailwind CSS, Framer Motion & More ✨ www.hover.dev
Today we're going to recreate one of the most popular effects on the web: Transforming vertical scrolling into horizontal scrolling.
Seen in just about every Awwwards website ever, this effect can be recreated with just a few lines of React and Framer Motion code.
We'll create a carousel style component, but this would work just as well with testimonials, text, or entire layouts.
We'll use Tailwind CSS, but all of the animation will be done with JavaScript, so you should be able to follow along just fine with normal CSS :)
📚 Project Links
live version and code: www.hover.dev/components/caro...
🔗 My Links
TikTok: / tomisloading
Instagram: / tomisloading
GitHub: github.com/TomIsLoading
Twitter: / tomisloading

Пікірлер: 61
@tomisloading
@tomisloading 11 ай бұрын
Okay i have no idea what happened to the audio in the last like 5 seconds of the video when I uploaded and I can't replace the file, but I promise you it wasn't anything important, just your typical end of video rambling😂😂😂
@mohaniya15
@mohaniya15 11 ай бұрын
The quality of your videos are pretty good tom! Makes me want to increase mine
@tomisloading
@tomisloading 11 ай бұрын
Haha, don’t worry, I still feel like I have no idea what I’m doing on the video editing side of things 😂😂
@mirage4731
@mirage4731 19 күн бұрын
This was damn easy to understand, thank you for the video
@yuktijhawar6729
@yuktijhawar6729 11 күн бұрын
Thank you so much for the video... You solved a very major problem of mine
@mistersir3185
@mistersir3185 8 ай бұрын
Bro you're funny and you explained this really well. Thanks!
@slythespacecat
@slythespacecat 5 ай бұрын
Awesome video! Thank you so much
@AviralTuteja-bp3ho
@AviralTuteja-bp3ho 2 ай бұрын
I have been stuck on this problem for 3 days, thank you for this video. Turns out I was using fixed instead of sticky.
@marianakoudela2760
@marianakoudela2760 6 ай бұрын
This is exactly what I needed, thank you!
@tomisloading
@tomisloading 6 ай бұрын
Happy to help! :)
@kernelgm
@kernelgm 4 ай бұрын
Thank you, bro! Help me a lot.
@nushen88
@nushen88 6 ай бұрын
you just got a sub haha love your humor
@essenc3189
@essenc3189 4 ай бұрын
thank you for this animation webpage mate
@tomisloading
@tomisloading 4 ай бұрын
Thank you so much!! 😁
@blablalagence5013
@blablalagence5013 9 ай бұрын
Hybrid and Locomotive scrolling are the names of those!
@davidlintin
@davidlintin 4 ай бұрын
Hey @Tom would love to see a video on how you go about figuring out the animations. I.e the game plan and how you’d approach the solution. Great videos. ✌🏻
@tomisloading
@tomisloading 4 ай бұрын
That’s a great idea!! I’ll think about that for sure :)
@tamerahmed9860
@tamerahmed9860 11 ай бұрын
If you make a course about framer motion in react, I will buy it! Please make more projects! Thanks
@germanpinto883
@germanpinto883 11 ай бұрын
Great video 🎉
@tomisloading
@tomisloading 11 ай бұрын
Thank you! :)
@taunado
@taunado 10 ай бұрын
Thanks
@gunnercat8045
@gunnercat8045 Ай бұрын
althought it is very good, wouldnt it be a problem when there is more item to be added if the transition is on percent?
@michaelxaviercanonizado7931
@michaelxaviercanonizado7931 6 күн бұрын
adding more content (Cards) shouldn't cause any issues. The only thing that would change is the speed at which the carousel will move. Since the height of the large container (h-[300vh]) is being distributed amongst the width of the Cards container. There shouldn't be any problem. Just increase the large container size to vary the speed
@lazimmv
@lazimmv 11 ай бұрын
Can we just make div flex row and overflow y hidden?
@feastofsteven1214
@feastofsteven1214 4 ай бұрын
Great video man, thanks! One thing I've had trouble with, and I've tried it every which way --- I cannot for the life of me get the background image to display through the URL. To clarify: I'm using jsx, I copied the javascript code from your site, and I'm pulling my images from an 'img' folder inside the 'src' folder. I've tried using ./ and ../ because sometimes I need to go up a directory or two for it to find it, but that hasn't worked. I even tried moving the images to the public folder to see if it worked, still nothing. I know I'm missing something simple, but can't figure what? Do I need to import the images if they are local or something? Any help is greatly appreciated, thanks!
@CeezGeez
@CeezGeez 8 ай бұрын
noice
@AlbertoLeo_
@AlbertoLeo_ 5 ай бұрын
Can it works with videos instead of card (images)?
@djimenezweb
@djimenezweb 3 ай бұрын
Someone having overflow issues? I'm trying to replicate this effect using Next.js 14.1.1 and Tailwind 3.3.0 and the carousel element keeps overflowing. Not only it overflows, but it is causing all the parent elements, including body and html, to be wider than they should! I've tried every possible combination of overflow-hidden, overflow-x-hidden, overflow-clip... It's driving me nuts! Any ideas? PS: SOLVED! It turns out that my grid layout was the cause. I had grid-template-rows: 1fr auto 1fr and forgot to declare grid-template-columns.
@Ven0mHQ
@Ven0mHQ 3 ай бұрын
How could I center an element when the user stop scrolling?
@divadolleh
@divadolleh 4 ай бұрын
Do you have a vertical version that could guide us?
@aburex705
@aburex705 11 ай бұрын
Great job❤ Is there anyway I can find the design animation of the horizontal scroll thing on framer or figma?
@tomisloading
@tomisloading 11 ай бұрын
Thank you! Unfortunately I’m not sure, I don’t have anything I could provide personally but there might be something similar around somewhere 🤷🏼‍♂️
@wizardfed1221
@wizardfed1221 11 ай бұрын
How would you fix so that when it reaches the end its equal to the left side black space, ive tried different % values but in different sized screens the values becomes wrong and parts of the last cards gets hidden
@whatyoumissed9994
@whatyoumissed9994 8 ай бұрын
use view port instead of pixels, view port is relative to the window unlike pixel that is absolute
@whatyoumissed9994
@whatyoumissed9994 8 ай бұрын
here is a code sample , i hope you are good with math, you get to use equations of a line to map two diffrent point which is the screen size and the view port const ref = useRef(); const { scrollYProgress } = useScroll({ target: ref, offset: ["start end", "end start"], }); const [screenWidth, setScreenWidth] = useState( typeof window !== "undefined" ? window.innerWidth : 0 ); useEffect(() => { if (typeof window !== "undefined") { const updateScreenWidth = () => { setScreenWidth(window.innerWidth); }; window.addEventListener("resize", updateScreenWidth); return () => { window.removeEventListener("resize", updateScreenWidth); }; } }, []); function calculateSecondValue(window) { //this equation is a gradient equation y=mx+c adjust it with your points for smallest screen and largest screen return `-${-0.31 * window + 555}vw`; } const x = useTransform( scrollYProgress, [0, 1], ["0vw", calculateSecondValue(screenWidth)] );
@kennedyfreitas7548
@kennedyfreitas7548 11 ай бұрын
just want to say, i visited your website and it' pretty cool,
@tomisloading
@tomisloading 11 ай бұрын
Thank you!! Working really hard on it haha :)
@knvsf2829
@knvsf2829 11 ай бұрын
@@tomisloading it definitely shows, I’m even planning on getting getting the lifetime subscription (which seems reasonable in pricing )
@tomisloading
@tomisloading 11 ай бұрын
@@knvsf2829 that’s awesome!! 😁😁 it’s my main focus right now outside of work. Plan to 5-10x the number of components + have some other tools I want to build and include :)
@knvsf2829
@knvsf2829 11 ай бұрын
@@tomisloading truly an amazing concept you’ve built man, excited to see the growth
@tomisloading
@tomisloading 11 ай бұрын
@@knvsf2829 thank you for the kind words, it’s genuinely extremely motivating hearing great feedback like this 😭😁
@krims254
@krims254 10 ай бұрын
hi, awesome little component, im stuck on one thing. On useTransform i start with 0% and i want to end the scroll animation when it reaches basically the very end div. using -% is not the outcome im looking for. another thing is why did you use 300vh and not 100vh for example? help would be appreciated.
@tomisloading
@tomisloading 10 ай бұрын
Not exactly understanding what your intended use case is, but I CAN answer the second question. The 300vh is because the wrapping div needs room to sticky scroll through the viewport. At 100vh, you'd scroll right past it since the inner div is also set to 100vh. Hope that helps! :)
@krims254
@krims254 10 ай бұрын
​@@tomisloading thanks for answering the 2nd question. Its a bit difficult describing the problem for the first question. non the less thanks.
@riteshmaharjan7011
@riteshmaharjan7011 6 ай бұрын
Hi, I am following your video to make my project but i am not running through all the projects. Basically this is what i have: const scaleProgress = useTransform(scrollYProgress, [0, 1], ["1%", "-100%"]); This is for the horizontal scroll to view all my projects but it doesnt go through all of it. This is what i have for my container it should increase the size of the scroll but it's not working as intended so i am not sure what to do. Any help would be appreciated. Thanks
@lukasgerhold7822
@lukasgerhold7822 5 ай бұрын
Your issue is that its not the section thats the motion element (at least in his example) but rather the div containing the images
@lucaapa
@lucaapa 11 ай бұрын
i want to do it vertical but i cant, just by chance you dosent have a vertical example? i've tried but candt doit
@tomisloading
@tomisloading 11 ай бұрын
Hmm, what exactly do you mean by vertical? Could you explain the desired outcome a bit more?
@giovannimh
@giovannimh 5 ай бұрын
scrollYprogress does not update somehow. When I console.log current value stays on 0.
@tomisloading
@tomisloading 5 ай бұрын
You won’t see updates by directly logging out scrollYProfress as it’s a MotionValue. You can see the latest value by passing it to the useMotionValueEvent and logging that value out :)
@BKBees
@BKBees 5 ай бұрын
This feature doesn't seem to work properly on mobile. Any ideas as to why?
@tomisloading
@tomisloading 5 ай бұрын
Hmm, it should! If you take a look at the version on my website on mobile it should work as expected. Could also be a specific browser/version issue?
@BKBees
@BKBees 5 ай бұрын
The issue seems to be that it doesn't start the horizontal scroll until the items are already past the viewport. When you're scrolling up it works. And mind you, it works perfectly on desktop, scrolling up and down.
@mauiboss5242
@mauiboss5242 3 ай бұрын
@@BKBees did you find a fix or an alternative?
@amansoni8670
@amansoni8670 9 ай бұрын
i want to do snap with each cards how to do that
@amansoni8670
@amansoni8670 9 ай бұрын
btw great content keep going
@IsebellaStone
@IsebellaStone 9 ай бұрын
I dont know how to add this code my framer project can u help me?
@tomisloading
@tomisloading 9 ай бұрын
Hi! Unfortunately I’m not an expert on framer as a platform. I believe it would be possible with their “overrides” feature but I wouldn’t be able to help much beyond that :(
@IsebellaStone
@IsebellaStone 9 ай бұрын
@@tomisloading no no ı want use this in framer how can use where ı need to paste this code on framer pls help me
@divyanshrana4257
@divyanshrana4257 10 ай бұрын
you were suppose to make videos on how you made your website on framer...where are the videos.
@tomisloading
@tomisloading 10 ай бұрын
Framer motion my friend, not Framer itself! 👍
The Framer Motion Crash Course || React Animation Library 2023
52:36
Tom Is Loading
Рет қаралды 90 М.
Infinite scrolling carousel with hover effects using Framer Motion
22:40
Nastya and SeanDoesMagic
00:16
Nastya
Рет қаралды 34 МЛН
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
Я обещал подарить ему самокат!
01:00
Vlad Samokatchik
Рет қаралды 7 МЛН
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 61 МЛН
Build a Smooth Scroll Cards Parallax with Framer Motion and Next.js
18:26
TailwindCSS Is Ugly. Here's How To Deal With It.
10:32
Tom Is Loading
Рет қаралды 7 М.
Complex Animations with Framer Motion & React || useAnimate Hook
13:48
Create Crazy 3D Image Slider Effects Using CSS Only
14:07
Lun Dev
Рет қаралды 216 М.
My Top 5 Techniques for Web Animation
9:58
Olivier Larose
Рет қаралды 61 М.
Smooth Loading Transitions with Framer Motion | AnimateSharedLayout
21:16
Horizontal Text Effect on Scroll - Framer Motion & React.js
9:07
Framer Motion Scroll-Based Animation with useScroll Hook
15:42
Nastya and SeanDoesMagic
00:16
Nastya
Рет қаралды 34 МЛН