flackr / scroll-timeline

A polyfill of ScrollTimeline.
Apache License 2.0
979 stars 95 forks source link

Parse full animation-range syntax #251

Open johannesodland opened 9 months ago

johannesodland commented 9 months ago

Implements parsing the full animation-range syntax to fix https://github.com/flackr/scroll-timeline/issues/236

Changes:

The tests for animation-range are not strictly unit tests and tests the implementation through the internal parseAnimationRange() function. The functionality is currently only exposed through css parsing which makes it difficult to test. We could expose the parsing partly through CSSStyleValue.parse('animation-range', value) but then we would have to proxy that method in all browsers.

calinoracation commented 7 months ago

Edit: Nevermind, our atomic css parser split the rules out so it couldn't parse it correctly.

~@bramus @johannesodland Any chance of landing this? We're trying to use some code like this and it's not parsing at the moment. In Chromium it works great.~

    animation-duration: 1ms;
    animation-fill-mode: forwards;
    animation-name: overflow-visible;
    animation-range-start: entry 70%;
    animation-range-end: entry 100%;
    animation-timeline: --carousel-scroller;
    view-timeline-name: --carousel-scroller;

    @keyframes overflow-visible {
      from {
        opacity: 1;
      }
      to {
        opacity: 0;
      }
    }
callie-openai commented 1 month ago

@bramus @johannesodland Any chance this might still land? I'm trying to use syntax like the following for an effect to hide items going underneath a sidebar header but the current polyfill doesn't work with it.

animation-timeline: view();
animation-range: exit calc(0% - 160px) exit calc(0% - 145px);
/* ^ The 160px is the height of my sticky header */

Example of desired effect working in Chrome:

https://github.com/user-attachments/assets/8788cf84-2f58-43e4-9392-b9b7ee14bbae