Skip to content
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][css-animations-2] animation short-hand support for new properties #8054

Open
flackr opened this issue Nov 9, 2022 · 11 comments

Comments

@flackr
Copy link
Contributor

flackr commented Nov 9, 2022

scroll-animations-1 upgrades animation-delay to both be a shorthand for animation-delay-start and animation-delay-end as well as to support a new syntax for each of animation-delay-start and animation-delay-end of <timeline-range-name> <percentage> and just a <timeline-range-name> by itself for the overall property. Note that issue #7901 is bikeshedding some of the particulars but the high level is that more values will be part of animation-delay.

Since animation-delay is also part of the animation short-hand we also have to make sure that these new values can be uniquely parsed and differentiated from other properties in that shorthand. Issue #6946 touches on the general difficulty of extending the animation shorthand.

If we assume the format of <animation-delay> within the animation property is the same, we will have a compat risk with any named ranges which could overlap with animation keyframe names (i.e. currently cover, contain, enter, exit but potentially user defined range names in the future), as well as limit the ability to add any other numerical properties which could be confused with the offsets (currently percentages but #7575 will likely add lengths as well).

After discussing this with @andruud, we think functional notation would make animation delays unambiguous w.r.t animation-names or other future values which may also want to specify lengths, times, percentages. Specifically, we could add two functions (open to bikeshedding names):

  • offset(<timeline-range-name> <percentage>) would map to an animation-delay, the first occurrence being start delay and the second being end delay. (Alternate name ideas: delay to be consistent with underlying property)
  • range(<timeline-range-name>) would map to animation-delay: <timeline-range-name> 0% <timeline-range-name> 100%.

The scroll-animations spec also builds on the ability to specify an animation-timeline which has additionally been added to the animation shorthand in css-animations-2. The spec doesn't currently explain how to disambiguate a named timeline from an animation-name, but we could either use the positions like we do to currently differentiate duration and start delay or we could add a function for this as well, e.g. timeline(<timeline-name>) to unambiguously specify a timeline. We could keep the existing support for referring to anonymous timelines since those already have a functional notation. Open to other ideas here. @tabatkins

@ydaniv
Copy link
Contributor

ydaniv commented Nov 17, 2022

A few questions:

  • Any reason to prefer offset(<timeline-range-name> <percentage>) offset(<timeline-range-name> <percentage>) over offset(<timeline-range-name> <percentage>, <timeline-range-name> <percentage>)? I guess the latter maps better to a single delay value that is expected today, or is there an intent to add end delay to the shorthand's definition?
  • Is <percentage> mandatory? Or defaults to 0%/50%?
  • How about optional percentages for range() ? Like range(<timeline-range-name>[, <percentage>][, <percentage>]), first for start and second for end.

@ydaniv
Copy link
Contributor

ydaniv commented Nov 20, 2022

Another question:

It used to be common for scroll-linked animations, which were all based on ScrollTimeline-like implementations, to use a start offset (delay) and pixel-duration (duration), rather then an end offset (end delay). Though this technique may be obsolete with the invention of ViewTimeline, I think it may still be worthwhile to allow specifying a timeline either by a duration or and end-offset.

Is there a way to achieve this? I guess simply using positive/negative values won't work, perhaps with using offset() and range() with ScrollTimeline?

@flackr
Copy link
Contributor Author

flackr commented Nov 23, 2022

  • Any reason to prefer offset(<timeline-range-name> <percentage>) offset(<timeline-range-name> <percentage>) over offset(<timeline-range-name> <percentage>, <timeline-range-name> <percentage>)? I guess the latter maps better to a single delay value that is expected today, or is there an intent to add end delay to the shorthand's definition?

The intent would be to add end delay to the shorthand definition, though putting the start and end in one function is also fine with me. This could be delay or range, whichever we go with in #7901.

  • Is <percentage> mandatory? Or defaults to 0%/50%?

I would prefer it being mandatory, though if we have a positional function like you proposed it might be reasonable to default to 0% for the start range / delay and 100% for the end range / delay.

  • How about optional percentages for range() ? Like range(<timeline-range-name>[, <percentage>][, <percentage>]), first for start and second for end.

Isn't this just becoming the same as the offset function?

@flackr
Copy link
Contributor Author

flackr commented Nov 23, 2022

It used to be common for scroll-linked animations, which were all based on ScrollTimeline-like implementations, to use a start offset (delay) and pixel-duration (duration), rather then an end offset (end delay). Though this technique may be obsolete with the invention of ViewTimeline, I think it may still be worthwhile to allow specifying a timeline either by a duration or and end-offset.

Is there a way to achieve this? I guess simply using positive/negative values won't work, perhaps with using offset() and range() with ScrollTimeline?

This issue is merely to decide on the syntax for the animation shorthand ideally avoiding parsing ambiguity. It is a helper for all of the longhand properties. If in #7575 we decide to go with allowing lengths there then we would allow them here as well.

@flackr
Copy link
Contributor Author

flackr commented Dec 2, 2022

I suspect this is a nice to have but that we could not support the new properties and values in the short-hand for the initial version.

@flackr flackr added the Agenda+ label Dec 2, 2022
@fantasai
Copy link
Collaborator

fantasai commented Dec 6, 2022

(Agreed that it's not necessary to support the new features in the animation shorthand to start with.)

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [scroll-animations-1][css-animations-2] animation short-hand support for new properties, and agreed to the following:

  • RESOLVED: New features are not added to the animation shorthand (for now), they're just reset
The full IRC log of that discussion <fantasai> s/Topic/Subtopic/
<TabAtkins> fantasai: proposed resolution is we don't need to support new features in the 'animation' shorthand
<TabAtkins> (agreed, the animation shorthand is already a trash fire of parsing)
<TabAtkins> fantasai: We might come up with a good idea for later, but for now
<TabAtkins> astearns: Close the issue, or tag it to a different level?
<TabAtkins> fantasai: tag it
<TabAtkins> astearns: so proposed resolution is "not now"
<TabAtkins> dbaron: The shorthand is still resetting those new props, just can't set them?
<TabAtkins> fantasai: yes
<TabAtkins> RESOLVED: New features are not added to the animation shorthand (for now), they're just reset

@cdoublev

This comment was marked as off-topic.

@flackr

This comment was marked as off-topic.

@fantasai

This comment was marked as off-topic.

@fantasai

This comment was marked as off-topic.

@fantasai fantasai removed the scroll-animations-1 Current Work label Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Agenda Scratchpad
New Features
March 2023 VF2F
Monday - Mar 20
Development

No branches or pull requests

6 participants