-
Notifications
You must be signed in to change notification settings - Fork 693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[scroll-animations-1] Bring back Scroll Offsets #7575
Comments
Isn't it what we have |
Ok, just checked and we did lose that ability on |
I’ve given this some thought over the weekend, and could think of a few possible scenarios to tackle this:
|
This feels very similar to issue #7296 though I like some of the suggestions to handle this in a way similar to the way enter/exit phases are handled for ViewTimeline (See #7044). Following that thread, I think rather than offsets we could use whatever we decide the new shorthand for specifying start and end delay to set the range of the animation, e.g. #coverheader {
animation-delay: 0 90vh, 90vh 100%; /* Same as setting startDelay to 0 and 90vh respectively and endDelay to 90vh and 0 respectively. */
} |
Yes, since we already decided, at least for now, that these are properties of the animation, and not of the timeline. So these should go, as @flackr said above, on the Though this still makes @bramus's no. 2 suggestion valid, at least conceptually, with regard to the |
The extra added phase would leave the path for future additions open. Say a When no explicit phase is defined in the keyframes, the phase could be implied from the usage: adding non-phased keyframes to a |
Some authors who have been playing around with the polyfill have raised similar issues, asking about offsets no longer being available.
The recent Motion One scroll library that enables JS-based Scroll-Linked Animations also offers this ability. As @flackr suggested above, it could be achieved by having
|
FWIW I was thinking allowing lengths or percentages for ranges would allow greater flexibility: animation-delay: [ <time> | <timeline-range-name>? [<percentage> | <length>]]+ Then you could use calculations within ranges, e.g. /* Starts 10px after entering until 10px before done entering. */
animation-delay: enter 10px enter calc(100% - 10px); |
Oh yes, great tweak! I like it! |
@fantasai Could we get input from you on this before the spec goes to FPWD? Would love to get this back in there before the spec moves forward. |
I like the idea of adding length-percentages to |
A few questions:
|
I don't think this use-case is relevant to consider. As I suggested in #7944, time for delay and duration only make sense for time-based animations and length makes no sense there. And vice versa, if the animation has a timeline which isn't time-based, duration is irrelevant (since it's always 100%), and time for delay makes no sense. If an author wants to include both in @keyframes fade-in {
0%, enter 20% {
opacity: 0;
}
100%, enter 100% {
opacity: 1;
}
} |
It doesn't matter if it's a use case or not, the behavior needs to be defined. |
Yes, what I mean is that IMO these cases, where length is applied to time-based animations and time applied to length-based animations, should be treated as invalid and ignored.
This should also remove ambiguity from |
@ydaniv We can't make property parsing conditional on the value of another property. :) So we have to do something different, either zeroing out the mistyped values or treating the properties as having their initial value or something. |
To summarize, I think we've got the following proposals up for debate:
@birtles Interested in your take on this discussion! |
Thanks for including me and sorry for the delay (I was away last week and forgot to update my GitHub status). I'm afraid I haven't been following the scroll animation discussion very closely so my input is probably not particularly valuable. Two very high-level notes, however:
|
The CSS Working Group just discussed
The full IRC log of that discussion<flackr> q+<dael> Rossen_: Let's see if we can resolve on this one <dael> flackr: Given that animation-range specifies the range the animation runs in, if we add length as well I think it solves use case and don't need lengths added to delay <Rossen_> ack flackr <birtles> q+ <dael> birtles: I think that's good. Good to push it down the road and consider how it interacts with group effects <dael> fantasai: Prop: Add length % to animation-range to be used as offsets <dael> Rossen_: Objections? <dael> RESOLVED: Add length % to animation-range to be used as offsets <birtles> ("Pushing it down the road" here refers to adding lengths to animation-delay) |
I was under the impression we decided that |
@bramus unless I'm missing something, but from what I can see range names have no use with ScrollTimeline. ScrollTimeline should be using simple |
My original request for this issue was to be able to run a scroll-driven animation over a certain distance (in case of the header example: as you scroll the page from 0 to 90vh). The way I interpret the resolution, is that it would now be possible to do this as follows: @keyframes shrink {
from { height: 100vh; }
to { height: 10vh; }
}
#coverheader {
position: sticky;
top: 0;
animation-name: shrink;
animation-timeline: scroll(); /* 👈 Will find the root scroller */
animation-range: 0 90vh; /* 👈 Animation will run when scrolling from 0vh to 90vh */
} If that’s incorrect, then the resolution from #8298 (comment) might offer a solution, as it calculates the timeline ranges differently now. IUC correctly, the combined outcome would allow this: @keyframes shrink {
from { height: 100vh; }
to { height: 10vh; }
}
#coverheader {
position: sticky;
top: 0;
animation-name: shrink;
animation-timeline: view(self); /* 👈 Track myself */
animation-range: exit 0 exit 90vh; /* 👈 This works because of #8298 */
} |
If the header is stuck at In the first example: #coverheader {
position: sticky;
top: 0;
animation-name: shrink;
animation-timeline: scroll();
animation-range: 0 90vh;
} Will start the animation at In the second example: #coverheader {
position: sticky;
top: 0;
animation-name: shrink;
animation-timeline: view(self);
animation-range: exit 0 exit 90vh;
} Regarding the range start, animation won't start running while the header is stuck, because it's still in |
@bramus you are correct, the intent is to allow both with or without an animation-range as an alternative to a percentage on non-time based timelines. i.e. your first example should work. |
|
@flackr great! But then I think we have an ambiguity here, see #7575 (comment). Should I open a new issue for this? |
Sorry perhaps I'm just a bit slow today but can you explain the ambiguity? What's an example? Happy to see a new issue for that if you don't mind filing it. |
* Add <length> offsets to timeline range offsets * Add <length-percentage> values referencing the whole timeline * Tighten up definitions
@fantasai I've added comments in the commit on specific lines. |
@ydaniv Replied. OK to close the issue? |
@fantasai yes, thanks! |
One of the things that did not make it into the scroll-animations rewrite is the ability to animate as a scroller scrolls for a fixed distance. This used to be covered by the scroll-offsets.
There are some use-cases, such as this cover page that transforms to a header bar as you scroll over a distance of
90vh
.One could use use a
ViewTimeline
here, but not on the cover/header element itself because it is sticky and therefore neverexit
s. Instead, one would have to look at the succeeding element.This, however, is only possible if all of these apply:
enter
The first 2 conditions might not always be the case, but the author could work around that if they rearrange some things in their markup. The 3rd condition is not possible, since we decided in #7047 to have “timeline search look at preceding siblings and ancestors”.
Therefore I think we should reintroduce the Scroll Offsets.
The text was updated successfully, but these errors were encountered: