-
Notifications
You must be signed in to change notification settings - Fork 669
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] Allow optional <percentage>
in animation-range-*
#8438
Comments
This seems fine to me.
Discussed in #8552 already. I don't think there's any need to restrict things and allowing percentages < 0 or > 100% allows for specifying more cases, e.g.
This can't be enforced if they're in different ranges and in many cases whether one is before the other or not will be dynamic, e.g. contain 0% is usually after entry-crossing 99% but not if the element is larger than the viewport. TLDR I don't think we should try to enforce ordering and just let the math work out as it does. If you specify a 0 range then you'll have an animation that is always inactive.
Why not? We don't disallow things like
I've actually wondered whether it would be more intuitive for a single value range name / offset to be treated as an inset on the range. E.g. Expand
The range name is not naming a timeline, it's a named range within a timeline. This is setting the start and end points of the animation. It is valid for particular keyframes to be further refined to other phases. For example you could specify @keyframes frames {
contain 0% { transform: translateY(-10px); } /* contain 0% is equivalent to 0% given the animation-range. */
exit 0% { transform: none; opacity: 1; }
exit 100% { opacity: 0; } /* technically exit 100% is equivalent to 100% given the animation-range. */
}
.animate {
animation: frames;
animation-timeline: view();
animation-range: contain 0% cover 100%;
}
Yes, these probably should be separate. |
@flackr This is a super interesting idea. Should we spec it? :) |
Summary of proposed changes:
|
If we consider having defaults of 0%/100% I think it would be more useful to expand |
Thanks for the clarifications, some points were confused in my mind. I have re-read the entire spec but have no preference on which of the default values I would prefer ( |
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> -> https://github.com//issues/8438#issuecomment-1464672747<TabAtkins> fantasai: there was discussion about %s in teh syntax of animation-range <TabAtkins> fantasai: Can specify the shorthand to a name, but the longhands currently require a % <TabAtkins> fantasai: One proposal is to make that optional - if omitted it defaults to 0%/100% depending on prop <TabAtkins> flackr: sounds fine to me <bramus> +1 <TabAtkins> TabAtkins: +1 <TabAtkins> astearns: proposed resolution is to make % optional in animation-range-start/end, defaulting to 0%/100% <fantasai> PROPOSAL: Make <percentage> optional in animation-range-start/end, defaulting to 0%/100% <TabAtkins> RESOLVED: Make <percentage> optional in animation-range-start/end, defaulting to 0%/100% <fantasai> animation-range: name x% <TabAtkins> fantasai: if yous pecify `animation-range: name %`, currently it sets animation-range-start to that, and leaves -end as normal <fantasai> animation-range-start: name x%; animation-range-end: normal <fantasai> animation-range-start: name x%; animation-range-end: name (100 - x)% <TabAtkins> fantasai: The alternative is to expand it to this ^^ <TabAtkins> fantasai: so if you say "contain 5%", it'll set them to "contain 5%" and "contain 95%", so you're insetting from either end <TabAtkins> flackr: I put this forward bc it felt odd to take the specified % from the start, but ending in a potentially totally different animation range <ydaniv> q+ <TabAtkins> flackr: felt consistent with margin/padding that get spammed to the other side of the block. <astearns> ack ydaniv <TabAtkins> ydaniv: q is do we want to change the range as well - if start is "entry" do we use "exit" in the end? <TabAtkins> fantasai: Seems maybe too magical? Don't you want contain/cover? <TabAtkins> YehonatanDaniv: For those the proposal makes sense. Seems funky that for entry 5% we expand to entry 95% <TabAtkins> flackr: You can already use 'contain' to do that, but there are use-cases for keeping it in the same range. So i'd prefer not to. <TabAtkins> fantasai: I'd understand if you wanted to expand "name X%" to "name X%" and "name 100%" <TabAtkins> fantasai: so we'd take the name and set it to both longhands, but only use the % in start <flackr> animation-range-start: name x%; animation-range-end: name 100% <fantasai> animation-range: name x% <fantasai> 1) animation-range-start: name x%; animation-range-end: normal <fantasai> 2) animation-range-start: name x%; animation-range-end: name (100 - x)% <fantasai> 3) animation-range-start: name x%; animation-range-end: name 100% <TabAtkins> (this was gonna be my suggestion too - if the concern is just that setting 'end' to an unrelated phase, it seems reasonable to just set to that phase with 100%) <TabAtkins> flackr: good with 2 or 3 <TabAtkins> fantasai: Slight pref for 3, okay with 2 <TabAtkins> TabAtkins: prefer 3 <TabAtkins> emilio: Also prefer 3 <TabAtkins> emilio: 2 seems too magic <fantasai> TabAtkins: particularly, I don't know what 2 would do if you start at 55% :) <TabAtkins> astearns: Do we think we'll get a second % in animation-range at some point? <TabAtkins> fantasai: You can specify "name % name %" to end wherever you want <TabAtkins> fantasai: In theory we could say "name % %" default to the previous name <ydaniv> staying with 3 (: <TabAtkins> astearns: If we already have the syntax, no need to complicate until people ask for it <TabAtkins> astearns: So seems like we have option 3 consensus <TabAtkins> RESOLVED: When specifying "animation-range: foo X%", set the -range-end to "foo 100%" (staying in same phase, just setting to end) <fantasai> ACTION: file issue on 3-value syntax |
OK, edits are in f4a3db2. I added an example with the implications:
The last three are fallout from defining the shorthand as |
It could be fixed by defining I do not feel legitimate to give an opinion. You are much more invested in this spec than I am. That said it looks good to me, perhaps minus this potential typo: animation-range: entry;
animation-range-start: entry 0%;
- animation-range-end: exit 100%;
+ animation-range-end: entry 100%; |
Thanks @fantasai, I'd like to offer another option for omitted name. Since the complete timeline interval is represented by So that @cdoublev your change suggestion above seems correct. |
@cdoublev Thanks, fixed the error.
You're thinking through the implications and giving well-informed opinions, so imho your opinion is just as legitimate as mine. :) I have a bit more experience, so I have an advantage in being able to draw from that, but what matters here is how well a suggestion is thought through. And I think in that respect, your feedback is very helpful.
@ydaniv This wouldn't generalize to things other than View Timelines (which might no have a |
OK, I opened a separate issue for the 3-value shorthanding question at #8672. Going to close out this one since I think we're basically done with the original issue? (Re-open if you think I missed something else.) |
If I understand correctly, the
<percentage>
inanimation-range-start
andanimation-range-end
refers to a specified point on the timeline. Currently, when declaringanimation-range
with a single<timeline-range-name>
:So I wonder why
animation-range-start
andanimation-range-end
do not allow<percentage>
to be optional:It would default to
0%
inanimation-range-start
and100%
inanimation-range-end
.Also, I guess this
<percentage>
should be restricted to [0,100], so<percentage [0,100]>
, as well as in<keyframe-selector>
.I also wonder if:
<percentage>
should always be lower inanimation-range-start
than inanimation-range-end
normal
should not be allowed to repeatanimation-range: timeline-1 5%
toanimation-range-start: timeline-1 5%; animation-range-end: timeline-1 100%
(instead ofanimation-range-start: timeline-1 5%; animation-range-end: normal
<timeline-range-name>
is inappropriate in<keyframe-selector>
because I thinkanimation-range
defines an interval for all keyframes and an author is not supposed to declare eg.timeline-a 0% {} timeline-b 100% {}
withanimation-range: timeline-x
But these questions might deserve their own issue and I realize that these properties are currently under discussion so they may be a bit premature.
The text was updated successfully, but these errors were encountered: