-
Notifications
You must be signed in to change notification settings - Fork 715
[scroll-animations-1] Bring back Scroll Offsets #7575
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
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:
|
I strongly agree with this, but, I suppose, since we've already agreed we'll allow keyframe's offsets to be ranges etc. So this is no longer the case. Though I like the ergonomics of using |
Thanks @ydaniv.
Good point. I guess that ship has sailed. It would be nice to do some wholistic thinking about how all these units could combine harmoniously in the context of group effects where we may wish to use percentage values / ranges even when using a regular timeline. I've outlined the situation a little bit here and here but unfortunately no-one, myself included, has ever had time to look into it properly. I think it would be really fun to analyze these pieces in terms of layout terms. If you can picture the different intervals being laid out horizontally as boxes:
I think once you look at it in those terms, we can think of natural ways to have percentages resolve (e.g. if a group effect specifies a duration, it behaves like I'm not really sure what the equivalent for a timeline would be though? |
This is tracked in #7059. I proposed there the full set of transition timing functions to allow for developers to fully customize the easing. Just using |
The CSS Working Group just discussed The full IRC log of that discussion<dael> Rossen_: This is a fairly long issue<Rossen_> Initial Proposals Summary: https://github.com//issues/7575#issuecomment-1207786782 Key follow-up comments: https://github.com//issues/7575#issuecomment-1209635142 https://github.com//issues/7575#issuecomment-1253314529 Second Proposals Summary: https://github.com//issues/7575#issuecomment-1306103577 Key follow-up comments: https://github.com//issues/7575#[CUT] <dael> Rossen_: You can follow initial proposals and key follow-ups from there ^ <dael> bramus: With the previous iteration of scroll linked animations that use scroll linked timelines and this is not in the re-write <birtles> q+ <dael> bramus: A few suggestions, 8 Nov comment from fantasai summeries. Add a length % for naimation delay and animation duration. That way you can drive scroll linked animation over spec distance <dael> Rossen_: On this side of the pond the comment is on Nov 7 <Rossen_> ack freereyes <Rossen_> ack birtles <dael> birtles: I'm not opposed to adding the different units to delay. Concern I raised is architectural. From API PoV there's 3 piecens, timeline, animations, effects. In css animation is blurred where delay is part of effect. <dael> birtles: Architecturally would like effect separate so you can reuse it. That was the initial idea for the API. <dael> birtles: I was a little concerned about putting in a delay because that's part of effect and makes it harder to reuse <flackr> q+ <dael> birtles: One thought I just had there is another issue about overlap between animation range and delay. Was wondering if there's a possiblity to use animation range for this and have animation range apply to animation and animation delay apply to the effect. If we could satisfy the use case though that. Just a thought <dael> bramus: That would still allow % for length but not delay <Rossen_> ack flackr <dael> birtles: I wondered if it applies to animation not effect architecturally more suitable <dael> flackr: I think this does make use cases possible. I don't have any objection to it. Only concern is that delay does have units and it's time and they don't convert to the timelines of the effects. Have architectural breakage no matter which way we go. Not opposed, but don't think can avoid mixing units <dael> birtles: I think % have slightly different case to vh units. If you can have effects defined in terms of % that's more reusable. If you have an effect that interpolates between these values over a range in the abstract and than animation maps to concrete. <dael> birtles: % units and the general case of lengths I'm not opposed. nice if authors can achieve this without painting into a corner where they can't reuse the effect <flackr> q+ <Rossen_> ack fantasai <dael> fantasai: Two comments. 1 in terms of % I think % and absolute units need to be mixed. Sometimes you want absolute shift and sometimes you want relative and we combine. I don't think only % would work <dael> fantasai: I think before we resolve we should jump to next issue, discuss, and then bring those decisions to this <dael> flackr: You were concerned about resuability. The length values when used on a time-based timeline compute to 0 so the value are as effective as if they're in separate property. I think it's as resuable either way except you can't have a separate time-based delay <birtles> q+ <Rossen_> ack fantasai <dael> flackr: Also think delay is times so we will have to support % and times. It's hard to have a single unit world <dael> birtles: With regards to fantasai point of absolute and relative I agree. We have absolute and relative times if we have % <dael> birtles: Regards to reusability, on the original proposal there were 3 suggestions put forward. The third you can see the keyframes is un-effected. I guess that's an example of what I mean by reusable. It's only the second where keyframes change so maybe not important <dael> bramus: In the 3rd example that uses animation timeline offsets? <dael> birtles: Yes <bramus> https://github.com//issues/7575#issuecomment-1207786782 <dael> birtles: I was saying it's possible to use a % on an effect and an absolute unit on the mapping at the animation level so you can have lengths, 90 vh on the animation, and then map to % on effect so you can combine absolute units with % without introducing diff length types <Rossen_> q? <flackr> q+ <Rossen_> ack flackr <dael> flackr: In a previous breakout session and then with the group we resolved to have range-based offsets in keyframes which is laso a modification to keyframe spec that is incompat with a time-based animation <dael> flackr: Based on a strong dev demand to have animation with entry and exit effect that are dynamic calc of points in scroll <birtles> q+ <dael> flackr: Feel like that ship has sailed a bit to keep everything as % <dael> flackr: I think for simple animations you will be able to reuse them. For things linked to position on length-based timeline it's not portable <dael> birtles: yeah, maybe ship has sailed. Would be nice to have animation tied to mapping, but maybe too late <dael> birtles: Other thing is was thinking with this use case we could realize without going further. But maybe say that's how things work now. Fair enough <Rossen_> ack fantasai <dael> fantasai: My suggestion is pause the convo, switch to next topic. I think a couple of these ideas are linked to next topic <dael> Rossen_: We can do that unless everyone feels we're getting toward resolution <dael> Rossen_: I see birtles moved himself along <dael> birtles: If next issue is related we should do that first |
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: