| ▲ | mpeg 7 hours ago | |
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 | ||
| ▲ | dandep 5 hours ago | parent | next [-] | |
OP here, thanks for asking. While the `perspective` technique works too, it has the downside of needing a careful combination of scroller elements and properties. This approach adds a single class to the image container and that's it. Plus you can control many aspects of the animation such as entry/exit ranges, and make it control other properties like opacity or color, for example. I know browser support is still lacking, but it will get there eventually. I'm not using this in production code yet, but I think it's useful to experiment with these new CSS APIs. | ||
| ▲ | semolino 2 hours ago | parent | prev | next [-] | |
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. | ||
| ▲ | som 6 hours ago | parent | prev | next [-] | |
No doubt quite a few folk with the same question. Keen to understand performance tradeoffs. Obvious comparison note would be that the "new" method currently enjoys somewhat limited browser support (no Firefox without a flag, and only since Safari 26) | ||
| ▲ | iainmerrick 6 hours ago | parent | prev [-] | |
I was wondering the same thing. That translateZ is a bit fiddly to get right, so I could believe this is a bit easier to use, maybe? And presumably this could be used for other properties besides position, like colors, opacity or blurs. | ||