w3c / w3c/csswg-drafts

[css-animations][web-animations] Animations based on absolute/wall time

Open
#13,664 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-animations-2 web-animations-2
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

Splitting off from https://github.com/w3c/csswg-drafts/issues/13655

It is sometimes necessary to schedule the start of an animation relative to an absolute (wall) time.
This is currently only possible to achieve by scheduling the animation to play using javascript.
Avoiding flashes of wrongly styled content is hard.

Additionally, if the animation should follow the wall time, its current time has to be synced with the wall time every time the animation is restarted. Otherwise the animation would play from its current hold time and be out of sync.

Scroll-driven animations on the other hand are automatically automatically aligned based on their range when they are played.

Proposal

Add functionality to allow an animation to automatically align its start time with a range start defined in "wall" time. Similar to scroll-driven animations it should support an auto duration on the effect.

const anim = new Animation(coolEffect);
anim.rangeStart = {
  rangeName: 'absolute', 
  offset: Temporal.ZonedDateTime.from('2026-01-01T00:00:00+01:00[Europe/Oslo]')
};
anim.play();
animation: --cool-animation 2s;
animation-range-start: absolute 2026-01-01T00:00:00+01:00[Europe/Oslo];

As wall-time does not progress monotonically, it might be necessary with a new timeline:

animation-timeline: wall-time(Europe/Oslo);

Use cases

1. An animation running for the duration of an event
animation: --event-animation;
animation-range-start: absolute 2026-03-01T00:00:00+01:00[Europe/Oslo];
animation-range-end: absolute 2026-04-15T00:00:00+01:00[Europe/Oslo];
2. A presentational clock that shows the wall time.
@keyframes --hand-rotation {
  from { rotate: 0deg; }
  to { rotate: 360deg; }
}

.minute-hand {
  animation: --hand-rotation 3600s infinite;
  animation-range-start: absolute 2026-01-01T00:00:00+01:00[Europe/Oslo]
}

Range names, timeline name and time formats up for bike shedding.
This proposal requires the ability to represent a zoned date time in CSS. It would be beneficial to be able to specify such a type both in absolute and in relative time, but I'm deferring that to a separate proposal.

Related proposals

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the proposal and the related issues 9710 and 13659, then review the existing CSS Animations and Web Animations specifications. The open questions include range names, timeline naming, time formats, and representing zoned date-times in CSS. Done would require a resolved, implementable specification change rather than a small isolated edit.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.