Re: [csswg-drafts] [web-animations-1] Alternative to FillAnimation: replace events (#3689)

Refining this further, I have two particular questions that might help clarify how this should behave.

One stems from something @danwilson mentioned on the [Animation at Work slack](https://damp-lake-50659.herokuapp.com/) (#waapi channel), and one is based on @flackr's [question above](https://github.com/w3c/csswg-drafts/issues/3689#issuecomment-469514572).

**1) Do we replace even if there are underlying animations?**

e.g.
```
Anim C ← Top of stack
Anim B ← Filling
Anim A ← Still playing
```
(Assume all animations target the same set of properties on the same element and all are additive.)

Do we replace `Anim B`?

**If we say "Yes"** → whether or not the `replace` event callback sets specified style using the styles from the replace event, the end result will be:

```
Anim C
Anim A
[ Specified style ]
```
which is clearly different. In this case script would need to know that there is an underlying effect so it can call `persist()`. We could expose that information in the event but that feels a bit awkward.

**If we say "No"** → Then script can naively just clobber specified style with whatever is passed in and generally the result will not change since, once `Anim A` ends, we'll end up dispatching a `replace` event on `Anim A` _then_ `Anim B`.

That's simpler but it will mean if you have a never-ending underlying animation, we'd never dispatch any `replace` events for the remainder of the stack (unless we extend `replace` events to cover unfinished animations too). In effect, there would be cases that can still leak.

**2) Do we replace only once _all_ properties are covered?**

I initially assumed so but the following case has me concerned:

```
Anim B ← Animates `left`. Additive. Still playing.
Anim A ← Animates `left` and `top`. Finished and filling.
```

So far, so good. `Anim A` is _not_ replaced since not all of its properties are replaced yet. Later, however, we trigger `Anim C` as follows:

```
Anim C ← Animates `top`. Still playing.
Anim B ← Animates `left`. Additive. Still playing.
Anim A ← Animates `left` and `top`. Finished and filling.
```

`Anim A` is now replaced so we drop it. If script doesn't handle the `replace` event and either set the specified style or call `persist()`, the output on the `left` property will change sharply since we will have just:

```
Anim C ← Animates `top`.
Anim B ← Animates `left`. Additive.
```

That's probably ok, but it might be a bit surprising that the output changes suddenly due to two unrelated animations.

An alternative might be to replace on a property-by-property basis but I think that would leak to a much more complex API and it's probably ok to expect authors to call `persist()` when they're dealing with complex layering of additive animations like this.

-- 
GitHub Notification of comment by birtles
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3689#issuecomment-469536667 using your GitHub account

Received on Tuesday, 5 March 2019 04:51:27 UTC