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

Add docs for CSS Scroll-driven animations #27075

Merged
merged 51 commits into from
Jun 26, 2023

Conversation

chrisdavidmills
Copy link
Contributor

Description

The Scroll-driven animations spec is mostly supported in Chromium 115. This PR adds content for the new properties, functions, and other syntax defined in this spec, plus some related features from CSS Animations Level 2.

See my research document for more details as to what has been added. Note that this document includes some specific comments about items that still don't seem to be supported correctly in Chrome. In some cases, they are waiting for bugs to be fixed, but if those bugs don't get fixed by the time of launch, we might have to revert a bit of BCD data.

Motivation

Additional details

Related issues and pull requests

Fixes #26544

@chrisdavidmills chrisdavidmills requested review from a team as code owners May 31, 2023 17:16
@chrisdavidmills chrisdavidmills requested review from wbamberg, estelle and bsmth and removed request for a team May 31, 2023 17:16
@chrisdavidmills chrisdavidmills marked this pull request as draft May 31, 2023 17:16
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs Content:WebAPI Web API docs labels May 31, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 31, 2023

Preview URLs (37 pages)
Flaws (2)

Note! 35 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/CSS/timeline-scope
Title: timeline-scope
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: css.properties.timeline-scope

URL: /en-US/docs/Web/CSS/CSS_animations
Title: CSS animations
Flaw count: 1

  • broken_links:
    • Can't resolve /en-US/docs/Web/CSS/CSS_Transitions
External URLs (7)

URL: /en-US/docs/Web/API/Element/animate
Title: Element: animate() method


URL: /en-US/docs/Web/CSS/CSS_scroll-driven_animations
Title: CSS scroll-driven animations


URL: /en-US/docs/Web/CSS/@keyframes
Title: @keyframes


URL: /en-US/docs/Web/CSS/animation-range-end
Title: animation-range-end


URL: /en-US/docs/Web/CSS/animation-range
Title: animation-range


URL: /en-US/docs/Web/CSS/animation-range-start
Title: animation-range-start

(comment last updated: 2023-06-26 06:17:07)

@dipikabh dipikabh self-requested a review June 7, 2023 22:19
@bramus
Copy link
Contributor

bramus commented Jun 14, 2023

Please note that a late change to the spec changed the syntax for scroll-timeline-name and view-timeline-name. They no longer accept <custom-ident> but need a <dashed-ident> instead (w3c/csswg-drafts#8746). All code example will also need updating because of this.

Furthermore timeline-scope doesn’t seem to be covered. I replaces scroll-timeline-attachment and view-timeline-attachment which were part of the spec before, but now omitted. (w3c/csswg-drafts#7759)

@bramus
Copy link
Contributor

bramus commented Jun 14, 2023

And oh, getCurrentTime also got removed from scroll-animations-1, as per CSSWG resolution in w3c/csswg-drafts#8765 (comment). The edit doesn’t seem to be published yet, though.

- `timeline` {{optional_inline}}
- : A property unique to `animate()`: the {{domxref("AnimationTimeline")}} to associate with the animation. Defaults to {{domxref("Document.timeline")}}.
- : A property unique to `animate()`: The {{domxref("AnimationTimeline")}} to associate with the animation. Defaults to {{domxref("Document.timeline")}}.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rangeStart and rangeEnd are missing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I originally left them out because they didn't seem to do anything. I think it was around the time when the implementation was in progress. They do seem to work now, although some of the value effects aren't what I'd quite expect. Do all of the value types as specced work, in your experience?

My descriptions are in my next commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my experience they seemed to work well. Only used the string variation though, where I – for example – set rangeEnd to "cover 100%" instead of an object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, I wonder whether I should just list the string values then, at least for now, while we investigate the other options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so to clear this up, I've added clear examples of the string values, and made the values used in the on-page example string values. If it turns out people want more information of examples on the other value types, we can always add them later.

- : Returns the time value in milliseconds for this timeline or `null` if this timeline is inactive.

## Instance methods
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is no longer part of scroll-animations-1, as per w3c/csswg-drafts#8765 (comment) resolution

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, I deleted this in my last commit, but it seems to be back again today. I've deleted it in my next commit.

- : The scrollbar on the block axis of the scroll container, which is the axis in the direction perpendicular to the flow of text within a line. For horizontal writing modes, such as standard English, this is the same as `vertical`, while for vertical writing modes, it is the same as `horizontal`.
- `inline`
- : The scrollbar on the inline axis of the scroll container, which is the axis in the direction parallel to the flow of text in a line. For horizontal writing modes, this is the same as the `horizontal` axis, while for vertical writing modes, this is the same as `vertical`.
- `vertical`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be y. vertical once was part of the spec, but no longer is as per w3c/csswg-drafts#8666 (comment) resolution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darnit. I fixed this on the CSS *-timeline-axis pages, but forgot about this one. Fixed now.

- : The scrollbar on the inline axis of the scroll container, which is the axis in the direction parallel to the flow of text in a line. For horizontal writing modes, this is the same as the `horizontal` axis, while for vertical writing modes, this is the same as `vertical`.
- `vertical`
- : The scrollbar on the vertical axis of the scroll container.
- `horizontal`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be x. horizontal once was part of the spec, but no longer is as per w3c/csswg-drafts#8666 (comment) resolution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darnit. I fixed this on the CSS *-timeline-axis pages, but forgot about this one. Fixed now.


- `block`: The scrollbar on the block axis of the scroll container, which is the axis in the direction perpendicular to the flow of text within a line. For horizontal writing modes, such as standard English, this is the same as `vertical`, while for vertical writing modes, it is the same as `horizontal`.
- `inline`: The scrollbar on the inline axis of the scroll container, which is the axis in the direction parallel to the flow of text in a line. For horizontal writing modes, this is the same as the `horizontal` axis, while for vertical writing modes, this is the same as `vertical`.
- `vertical`: The scrollbar on the vertical axis of the scroll container.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be y. vertical once was part of the spec, but no longer is as per w3c/csswg-drafts#8666 (comment) resolution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darnit. I fixed this on the CSS *-timeline-axis pages, but forgot about this one. Fixed now.


- `none`
- : The timeline has no name.
- `<custom-ident>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `<custom-ident>`
- `<dashed-ident>`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this in my next commit

## Syntax

```css
/* two values: one each for view-timeline-name and view-timeline-axis */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All names need updating to <dashed-ident> variations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I've updated all instances of custom_name_for_timeline to --custom_name_for_timeline.

@@ -32,8 +29,10 @@ Allowed values for `scroll-timeline-name` are:
- `none`
- : The timeline has no name.
- `<custom-ident>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `<custom-ident>`
- `<dashed-ident>`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- : An arbitrary custom identifier that can be used to reference the scroll timeline in an [`animation-timeline`](/en-US/docs/Web/CSS/animation-timeline).
Possible values are described in [`<custom-ident>`](/en-US/docs/Web/CSS/custom-ident).

- : An arbitrary custom identifier defining a name for a scroll progress timeline, which can then be referenced in an [`animation-timeline`](/en-US/docs/Web/CSS/animation-timeline) property. See [`<custom-ident>`](/en-US/docs/Web/CSS/custom-ident) for more details about permitted values.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- : An arbitrary custom identifier defining a name for a scroll progress timeline, which can then be referenced in an [`animation-timeline`](/en-US/docs/Web/CSS/animation-timeline) property. See [`<custom-ident>`](/en-US/docs/Web/CSS/custom-ident) for more details about permitted values.
- : An arbitrary custom identifier defining a name for a scroll progress timeline, which can then be referenced in an [`animation-timeline`](/en-US/docs/Web/CSS/animation-timeline) property. See [`<dashed-ident>`](/en-US/docs/Web/CSS/dashed-ident) for more details about permitted values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- : The timeline has no name.
- `<custom-ident>`

- : An arbitrary custom identifier defining a name for a view progress timeline, which can then be referenced in an [`animation-timeline`](/en-US/docs/Web/CSS/animation-timeline) property. See [`<custom-ident>`](/en-US/docs/Web/CSS/custom-ident) for more details about permitted values.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- : An arbitrary custom identifier defining a name for a view progress timeline, which can then be referenced in an [`animation-timeline`](/en-US/docs/Web/CSS/animation-timeline) property. See [`<custom-ident>`](/en-US/docs/Web/CSS/custom-ident) for more details about permitted values.
- : An arbitrary custom identifier defining a name for a view progress timeline, which can then be referenced in an [`animation-timeline`](/en-US/docs/Web/CSS/animation-timeline) property. See [`<dashed-ident>`](/en-US/docs/Web/CSS/dashed-ident) for more details about permitted values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 32?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 32 and line 34.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@chrisdavidmills
Copy link
Contributor Author

OK, in the first commit since @bramus reviewed, I have:

  • Added a timeline-scope page
  • Made sure that scroll-timeline-attachment and view-timeline-attachment are not included anywhere
  • Made sure <dashed-ident> details plus explanation is included in the timeline-scope and *-timeline-name pages
  • Made sure all examples use dashed idents for the timeline names.
  • Removed getCurrentTime()

I'll start working through all the above comments tomorrow.

@chrisdavidmills
Copy link
Contributor Author

@bramus OK, I've done some testing and it looks like all my changes have stuck this time. Let me know if you spot anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs Content:WebAPI Web API docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document scroll driven animations
4 participants