Earlier quoted context omitted.
That should also enable iOS style, scroll-offset bound animations, right?
Scroll linked animations are the best way to do that: https://web.dev/shows/http-203/Qf5wdXOxW3E Sadly no Safari support yet. (attaching an active JS event listener to scroll is considered bad because it means your scroll movement gets tied up in the JS event loop. On a fast device it’ll probably be fine but on a slower one things can start getting choppy pretty easily)
Time-Based CSS Animations
41–49 of 49 posts
Re: Time-Based CSS Animations
#42Earlier quoted context omitted.
Scroll linked animations are the best way to do that: https://web.dev/shows/http-203/Qf5wdXOxW3E Sadly no Safari support yet. (attaching an active JS event listener to scroll is considered bad because it means your scroll movement gets tied up in the JS event loop. On a fast device it’ll probably be fine but on a slower one things can start getting choppy pretty easily)
Unfortunately if you're doing any sort of DOM manipulation linked to scroll events it will cause stalls in the main rendering thread, at least on Chrome, and slow down even on faster machines.
Re: Time-Based CSS Animations
#43Earlier quoted context omitted.
Unfortunately if you're doing any sort of DOM manipulation linked to scroll events it will cause stalls in the main rendering thread, at least on Chrome, and slow down even on faster machines.
The exception there is hardware accelerated CSS transforms, which will work great.
Re: Time-Based CSS Animations
#44Earlier quoted context omitted.
The exception there is hardware accelerated CSS transforms, which will work great.
"hardware accelerated" CSS transforms take ~30% of one CPU thread in Chrome, thats a very specific definition of great :(
Re: Time-Based CSS Animations
#45Earlier quoted context omitted.
The exception there is hardware accelerated CSS transforms, which will work great.
"hardware accelerated" CSS transforms take ~30% of one CPU thread in Chrome, thats a very specific definition of great :(
Re: Time-Based CSS Animations
#46I wanted this for a while so I could do a 'box-breathing' thing. With the inhale-hold-exhale-hold stages all being customizable to fit your body and go for the effect you wanted. Could not figure out a way to do it (sans JS or insane complexity) without something like what's on this page. Holy stylesheets! This page has really creative demos!!! Haha :)
Re: Time-Based CSS Animations
#47CSS now has enough Math functions supported, particularly mod(), round(), and trigonometric functions CSS can not start a timer like JavaScript does, but nowadays it's possible to define a custom variable with the CSS Houdini API to track time in milliseconds. Why do we need all this when we have JavaScript? Shouldn't the drawing layer be concerned with drawing primitives? Why put more and more of the higher layers i…
Don't forget that CSS animations are hardware accelerated. If you're doing trig in JS for animations, you're probably also manipulating the DOM to update the UI every millisecond, which is very expensive
Re: Time-Based CSS Animations
#48I wanted this for a while so I could do a 'box-breathing' thing. With the inhale-hold-exhale-hold stages all being customizable to fit your body and go for the effect you wanted. Could not figure out a way to do it (sans JS or insane complexity) without something like what's on this page. Holy stylesheets! This page has really creative demos!!! Haha :)
Isn't that just an animation curve in css?
I'm thinking of a customizable CSS version of: https://quietkit.com/box-breathing/
Re: Time-Based CSS Animations
#49Earlier quoted context omitted.
Isn't that just an animation curve in css?
I couldn't figure it out. I mean, could you have a go at it? Like I want each of the 4 edges to be parameterizable (by a CSS var) so I can add a slider to adjust how long the circle stays in each of the states. I'm thinking of a customizable CSS version of: https://quietkit.com/box-breathing/
https://codepen.io/spartanatreyu/pen/YzbPjwg?editors=1100
But if you want each step's duration to be parameterizable then you'll need to reach for js, I'd recommend the Animation API.