Re: [csswg-drafts] [css-transitions-2][css-animations-2] The event order of the cancelled transitions/animations (#11064)

> Also, we have the similar issue for `animationcancel` (in [css-animations-2](https://drafts.csswg.org/css-animations-2/#animation-composite-order)), and we probably need to figure out how to use `animation-name` for a cancelled animation.

I had a bit of a think about this. For CSS animations we [sort by](https://drafts.csswg.org/css-animations-2/#animation-composite-order):

1. Tree order
2. Position in the `animation-name` list

So how do we handle cancel events from animations that have been cancelled? Consider a few examples of changes to `animation-name` list with regards to cancel event ordering:

Case A: If we change `animation-name` from `a, b` to `c, b` we want to ensure the cancel event for `a` sorts before the start event for `c` since that's consistent with transitions and conceptually it makes sense to cancel old animations before adding new ones.

Case B: If we change `animation-name` from `a, b, c` to `c` we would probably prefer that the cancel event for `a` sorts before the cancel event for `b`. It's not very important but we need to define _some_ order and `a, b` seems the most obvious one here.

Case C: What if the `animation-name` is originally `a, b, c`, then, in a separate style change updated to `b, a, c` and then later updated again to `c`? It would probably be most consistent for the cancel event for `b` to the dispatched before the cancel event to `a` since `b` appeared before `a` in the `animation-name` at the point when they were cancelled.

Given that, I think we could sort as:

1. Sort by owning element
2. Sort by position in the animation list. If either animation has been cancelled, use the position they were in the list when they were cancelled but treat such positions as sorting before all positions in the current list.

So, for example, if both A and B have been cancelled, we just sort by the old positions in the list.

If only A or B has been cancelled, the cancelled animation sorts first.

If neither A nor B have been cancelled, we sort by the positions in the current list.

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 30 October 2024 03:55:10 UTC