Me, on stage. Photo by devs.gent.Today I gave a talk at the September 2024 devs.gent meetup on how to observe and respond to Style Changes.
~
Table of Contents* The Talk * Slides * Recording/Video * Thanks!
~
@bramus/style-observerA shortcoming of
MutationObserveris that it cannot be used to subscribe to value changes of CSS properties.While you could resort to
requestAnimationFrameandgetComputedStyleto plug that hole (which you shouldn’t), there is a more performant way to achieve this: leverage the power of CSS transitions in combination with the fairly recenttransition-behavior: allow-discrete. With it, you can set up JavaScript callbacks to respond to changes in computed values of CSS properties – including Custom Properties.
This is basically a talkified version of this blog post.
~
These exported slides don’t contain any recordings of the demos included, but you can follow the links on the slides to check them out yourself.
~
~
~
💁♂️ If you are a conference or meetup organiser, don't hesitate to contact me to come speak at your event.