Feature detecting Scroll-Driven Animations with @supports: you want to check for animation-range too

You want to filter out Firefox’s partial implementation …


This content originally appeared on Bram.us and was authored by Bramus!

~

Scroll-Driven Animations versus Firefox

Ahmad recently launched a redesign of his website. On it he features some nice Scroll-Driven Animations to enhance the experience. As one should do, the CSS for it is gated behind an @supports result which feature detects availability for Scroll-Driven Animations.

@supports (animation-timeline: scroll()) {
  /* Scroll-Driven Animations related styles go here */
}

However, even though he gated the functionality behind a feature check, he got some reports from users that it wasn’t working as expected in Firefox: the animations would run on scroll but the timing would be waaaayy off. So he reached out to me, asking what gives.

The problem is that, at the time of writing, Firefox Nightly – which has Scroll-Driven Animations enabled – only has a partial implementation of it. They support a bit of it, but not everything. One of the things they do support is animation-timeline: scroll(), making Firefox Nightly pass the feature detection snippet from above.

~

Filtering out Firefox’s partial implementation

To filter out Firefox Nightly, you need to extend the feature detection for Scroll-Driven Animations to include a check for something they don’t support yet. For this, you can check for animation-range support, as that’s a property that is not part of their partial implementation.

Like so:

@supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
  /* Scroll-Driven Animations related styles go here */
  /* This check excludes Firefox Nightly which only has a partial implementation at the moment of posting (mid-September 2024). */
}

Here’s a live demo:

See the Pen
Feature detect scroll-driven animations support but exclude Firefox’s partial implementation
by Bramus (@bramus)
on CodePen.

That’s it 🙂

~

Spread the word

Feel free to repost one of the posts from social media to give them more reach, or link to this post from your own blog.

~


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2024-09-24T20:45:21+00:00) Feature detecting Scroll-Driven Animations with @supports: you want to check for animation-range too. Retrieved from https://www.scien.cx/2024/09/24/feature-detecting-scroll-driven-animations-with-supports-you-want-to-check-for-animation-range-too/

MLA
" » Feature detecting Scroll-Driven Animations with @supports: you want to check for animation-range too." Bramus! | Sciencx - Tuesday September 24, 2024, https://www.scien.cx/2024/09/24/feature-detecting-scroll-driven-animations-with-supports-you-want-to-check-for-animation-range-too/
HARVARD
Bramus! | Sciencx Tuesday September 24, 2024 » Feature detecting Scroll-Driven Animations with @supports: you want to check for animation-range too., viewed ,<https://www.scien.cx/2024/09/24/feature-detecting-scroll-driven-animations-with-supports-you-want-to-check-for-animation-range-too/>
VANCOUVER
Bramus! | Sciencx - » Feature detecting Scroll-Driven Animations with @supports: you want to check for animation-range too. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/24/feature-detecting-scroll-driven-animations-with-supports-you-want-to-check-for-animation-range-too/
CHICAGO
" » Feature detecting Scroll-Driven Animations with @supports: you want to check for animation-range too." Bramus! | Sciencx - Accessed . https://www.scien.cx/2024/09/24/feature-detecting-scroll-driven-animations-with-supports-you-want-to-check-for-animation-range-too/
IEEE
" » Feature detecting Scroll-Driven Animations with @supports: you want to check for animation-range too." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2024/09/24/feature-detecting-scroll-driven-animations-with-supports-you-want-to-check-for-animation-range-too/. [Accessed: ]
rf:citation
» Feature detecting Scroll-Driven Animations with @supports: you want to check for animation-range too | Bramus! | Sciencx | https://www.scien.cx/2024/09/24/feature-detecting-scroll-driven-animations-with-supports-you-want-to-check-for-animation-range-too/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.