29 comments

[ 4.2 ms ] story [ 58.4 ms ] thread
That sounds interesting but it would be a whole lot more interesting if the page was itself an example of said effect!
Or even linked to one!
I've put together an example here but it doesn't seem to work in Firefox 151.0.2 (64-bit): https://favs.eu.org/parallax/

Edit: if the body has class="no-sda", it uses a js fallback.

its beautiful! where can I track the compatibility?

and how do I know if I'm hitting the fallback?

I really like the fact that your "recipe" already includes support for prefers-reduced-motion. Parallax can really trigger motion sensitivity issues up to vomiting or several days of bed rest with severe migraine.

You did leave that part out of your recipe though. Would you mind adding it there, so that people who copy paste are more inclined to actually keep/use that part as well?

How does this compare to the classic css-native parallax effect? Before the scroll timeline APIs you'd use the "perspective" css property to create a container where the z plane is n pixels away from the screen, and then position each layer within it at a different z distance using transform: translateZ

That method is GPU accelerated too, so it is performant compared to some js solutions, and has worked well in every browser for around a decade

I like the idea of the scroll-timeline though, just keen to understand what the advantage is for this

This method should still support GPU acceleration, as `transform` (or rotate/scale/etc.) is the only property being animated. The benefit of animation-timeline seems to be that it's much easier to set up than a CSS perspective context.
When using Z, if the element is close to the bottom of the page, or a very large Z, I found it to increase the length of the scroll bar unexpectedly. Or unexpectedly to me looking for parallax, it would make sense as a normal zoom or scale.
You can make some really cool stuff with css scroll animations. I used SVG paths with a scroll animated dash offset to draw an image while scrolling. Zero javascript, it feels so smooth. https://thomaswelter.nl (the background)
oh that's cool!

Can only see it on chrome though =/. I switched to Safari as the lesser of two data-harvesting evils. Or rather, with an iPhone I've already chosen my overlord. I also switched to Kagi. Trying to deGoogle myself.

Love the one-variable design where scale and translate stay in sync automatically, just wish Firefox would get off the flag already.
In a world where it's increasingly overlooked, I'm glad the author mentions disabling it respecting user settings. I do think it should be reversed and only enabled with the `@media (prefers-reduced-motion: no-preference)`, but that is the opinion of someone who gets negative value from animations and is bemused by how much dev and compute time is spent on them.
It would be awesome to put an interactive example right in the article.
Idk about anyone here but I find the effect disorienting.
Slightly disorienting but mostly just gimmicky. Luckily the "scroll down and more stuff than just scroll i going on" trend has mostly faded.
I played around with this API some time ago. It’s simple and high-performance, but one feature I wish existed is damping. Scroll-driven animations are tied directly to the scroll timeline, so there’s no concept of the parallax object “catching up” to the scroll progress over, say, one second. From what I remember, `animation-timing-function` feels weird when you scroll, so it’s not the right solution. GSAP offers this, but it’s JS-only.
could this be combined with a sprite like image that shows a slightly different angle of the image with each step
Great. I tried the Google examples a while ago and got nowhere with it, time for another go, within the netherworld of SVG, to map to several different layers.
there is a special place in hell for pages like these that don't show examples
I was expecting a demo on the linked page itself. Interesting to let Codex or Claude Code do it :)
Using css perspective for parallax has been around for years and is much simpler code.
I get motion sickness from this specific effect. Especially on high refresh rate screens.
(comment deleted)