Loading video...

Video Failed to Load

Go Home

Future CSS Tip! 📜 You can create these landing page effects with CSS scroll-driven animations and zero JavaScript 🔥 Blurred text on exit? 👀 @​keyframes fade { to { opacity: 0; filter: blur(2rem); } } h2 { animation: fade; animation-timeline: view(); animation-range: cover 40% cover 85%; } Lots of...

426,307 views • 2 years ago •via X (Twitter)

9 Comments

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈2 years ago

Here's that @CodePen link! 🚀 You need to be in Chrome to see this in action 🥲 Will aim to create a polyfilled version using GSAP ScrollTrigger. Threw this together pretty quick/rough 😅

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈2 years ago

Will probably need to break this one down into mini posts for the different techniques going on here 🤔 It's mainly tricks with position: fixed and scoped view-timeline ⭐️

Billy191 🔴✨'s profile picture
Billy191 🔴✨2 years ago

Any implementation with @tailwindcss “

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈2 years ago

@tailwindcss Could totally throw one together. Will require some configured classes for the animation-timeline related properties, etc. Perhaps doing it in Tailwind play would be a good option 🤙

THIRDOCTAV's profile picture
THIRDOCTAV2 years ago

Make a video of this. Its 🔥🔥🔥

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈2 years ago

Will do! This is the push I needed 🙏 Will do a walkthrough of how the different pieces work

Nine's profile picture
Nine2 years ago

When can we expect a lot of these features to be stable in the future? Is it rather far away or let's say 1-2 years

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈2 years ago

@abuzackariyya It shouldn't be too far away, there is intent from other browser engines 🙌 But, I'll update the demo so it can be used with GreenSock too 🤙

busta's profile picture
busta2 years ago

looks amazing. when can stuff like this be available in Safari u think?

Related Videos

CSS Tip! 🐳 You can add little details like this scale down on scroll effect with scroll-driven animations and some sticky positioning 🤙 section { animation: scale-down; animation-timeline: view(); animation-range: exit; } @​keyframes scale-down { to { scale 0.8; } ] In this smaller example, you can lean into using the position to drive an animation that scales itself down as it leaves the viewport (Seen on the Apple Vision Pro site 🍏) The nice thing here is that if you don't have scroll-driven animations, the user still gets a good experience ✨ So how do you do it? There isn't much to it header { transform-origin: 50% 0%; animation: scale-down both ease-in; animation-timeline: view(); animation-range: exit; view-timeline: --header; } @​keyframes scale-down { to { scale: 0.8 0.8; } } That's it. The layout makes use of position: sticky so that the element stays in the shot whilst you scroll the page. As it leaves the page, it scales down inside the 🫶 The other smol animation here is fading the overlay on the video out 😎 Real easy. You may notice the view-timeline you defined above for the 👀 header { view-timeline: --header; } You have a pseudoelement on the text content of the header that lives inside a header > section::before { background: hsl(0 0% 0% / 0.75); opacity: 1; animation: fade both linear; animation-timeline: --header; animation-range: exit-crossing 0% exit 0%; } @​keyframes fade { to { opacity: 0; } } You use a slightly smaller range on this with exit-crossing to fade it out before you start the scale down animation 🤏 That's it! Thought this smaller example would be easier to grok for people 🙏 It's also covered with JavaScript if you really want it for your sites 🤙 CodePen.IO link below 👇

jhey ʕ•ᴥ•ʔ

146,064 views • 2 years ago

CSS Tip! ✨ You can create these parallax effects and image cross-fades with scroll-driven animations 🤙 img { animation: fade; animation-timeline: view(); mix-blend-mode: plus-lighter } img:last-of-type { animation-direction: reverse; } @​keyframes fade { to { opacity: 0; }} This one's fun! 😁 The trick with the cross-fading image is to make use of one animation that runs at the same time on two images inside a container. You use the same animation, animation-timeline, and animation-range. But, you use animation-direction: reverse on one of the images so they go in the opposite direction 🫶 The use of mix-blend-mode: plus-lighter; produces a better cross-fade result 💯 A viewTimeline (view()) works because you know that both images are the same height. The range you can use is img { animation-timeline: view(); animation-range: cover 45% cover 55%; } That means when the image has covered 45% of the scrollport (In this case, the window), start the animation. And finish when it has covered 55% 🎬 How about the slight parallax? This is a trick with calc(). You know the top of the small image and the big image line up. And you can do this by absolutely placing the caption outside of the small image. The trick is to translate the small image by a distance so it lines up with the bottom of the big image. You can do that like this :root { --catch-up: calc( var(--big-height) - var(--small-height) ); } @​keyframes move { to { translate: 0 var(--catch-up); }} Then drive that animation with a scroll-driven animation using the container of both images as the driver 🤙 /* section contains both images */ section { view-timeline: --container; } .img-fader { animation: catch-up both linear; animation-timeline: --container; animation-range: 50vh calc(100vh + (var(--big-height) * 0.25)); } That's it! Scroll-driven image cross-fading and parallax effects without any JavaScript. This demo will work in all browsers as there is some JavaScript in place where the API isn't supported 🤙 To do that, it uses GSAP ScrollTrigger 🏆 As always, any questions, requests, etc. hit me up! 🤙 CodePen.IO link below 👇

jhey ʕ•ᴥ•ʔ

241,952 views • 2 years ago