-
Notifications
You must be signed in to change notification settings - Fork 689
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
[css-animations-2] Specify the animation-trigger property #10128
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this started! I think some of the low level details of how an animation trigger affects the animation probably belong in web-animations-1 with the css-animations spec setting properties by which you set up those triggers declaratively. You should also of course be able to set the same properties from the web-animations api.
css-animations-2/Overview.bs
Outdated
An <dfn export>animation trigger</dfn> is used to control the playback | ||
of its associated [=animation=] for time-driven animations. | ||
[=Animation triggers=] follow the same [[web-animations-1#hierarchical|hierarchy]] | ||
as animations and are associated with a [=timeline=] and an [=animation trigger effect|effect=]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it sound like animation triggers are separate things from animations, but I suspect we should say that as a part of updating the current time of animations we evaluate whether a trigger condition has been reached and apply a stateful change to the animation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I'll work on that
css-animations-2/Overview.bs
Outdated
[=Animation triggers=] follow the same [[web-animations-1#hierarchical|hierarchy]] | ||
as animations and are associated with a [=timeline=] and an [=animation trigger effect|effect=]. | ||
|
||
Issue: Should there be any effect of triggers on scroll-driven animations? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect triggers on scroll-driven animations should "just work". E.g. they could play / stop the animation when the trigger condition occurs / finishes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does each type
affects a scroll-driven animation?
Furthermore, what could be the actual use-case for this? Perhaps one that I can think of now is if we have a hover-timeline
in the future and we want to enable/disable it on different scroll positions. Is that what you mean?
css-animations-2/Overview.bs
Outdated
:: | ||
|
||
<dl class=switch> | ||
: If |effect| is inside its [=active interval=], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think defining a trigger in terms of an internal animation effect's time might be overkill. E.g. I think we could define this simply in terms of the animation timeline's time with respect to the specified range
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I struggled with that quite a bit. Eventually it worked out once I defined the same hierarchy as animations', and defined a special state for the effect
. I'll try simplifying this further.
css-animations-2/Overview.bs
Outdated
|
||
Issue: Should there be any effect of triggers on scroll-driven animations? | ||
|
||
## Animation Trigger Effects ## {#trigger-effects} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the internal control of how triggers work probably belongs in web-animations where we define things like how an updated time updates corresponding animations: https://drafts.csswg.org/web-animations-1/#update-animations-and-send-events
We should also be able to set up animation triggers from javascript.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sure. We didn't discuss the WAAPI part of triggers in the issue, should I try fleshing that too in this PR? Or you're just stating this as a reason for this change?
@ydaniv Thanks for doing this. I started going through it today but I was a little confused about the hierarchy of components from the Web Animations API point-of-view. It sounds like we have the following parts:
What is the relationship between them? Do the Animation trigger and Animation share an effect? Is the Animation trigger connected directory to the Animation trigger effect or only via the Animation? Is the Animation attached to the Animation trigger timeline or just the Animation trigger? Sorry, I'm probably being really daft here but I couldn't grasp how the pieces fit together. Defining some of these primitives as Web Animations constructs like @flackr suggested might help clarify how they fit together. |
@birtles thanks for reviewing! The intention of the hierarchy was mostly to simplify the spec, by having triggers follow animations as in: The idea was that they don't share anything, just follow the same structure, and the trigger simply affects the animation's playback according to its properties and state. But, as @flackr mentioned, it's still too confusing and too complex, so I'll try and rewrite this without the effect part, and only with a trigger attached to a timeline and a range. I've tried defining the constructs first in the initial draft. I'll move those into the Web Animations spec as suggested, and try to organize them together again in a simpler way. |
Makes sense!
Ok, I'll look forward to seeing what you come up with! |
Removed dfn of animation trigger effect
web-animations-1/Overview.bs
Outdated
The [=animation effect=] associated with |trigger| remains in | ||
its [=animation effect/before phase=] and stays at zero [=animation/start time=]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't quite get the hierarchy here. This suggests an animation effect is associated with a trigger but previous we said a trigger is associated with an animation. Which is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the relation here should be indirect via the animation. The trigger is associated to the animation. The required behavior of the animation is to "hold its effect in a 'just before playing' state". I'll try to fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I think it's better now.
@ydaniv Sorry for the delay--currently on parental leave. Just a few meta points:
|
Thanks @birtles!
Congrats ^_^!
Ok, I also wondered about that, but @flackr wrote Web Animations 1, and some things I needed to update were actually there, so not sure whether this was intentional or not.
You mean the DOM interfaces, as in here?
I've added this text to that section:
Shouldn't this cover it? I think basically comes down to checking triggers state on timeline's current time update. |
Thanks!
Yeah, that would be good to know. My understanding is it should be level 2 but maybe @flackr has some ideas about that.
I was thinking about the Web Animations DOM interfaces. Just like we have the That also makes me wonder how authors would expect to be able to inspect these from script. Is there some way to fetch the triggers in a document? Or the trigger driving a particular
Yeah, I was thinking that we need to review the whole section to check for other references that need to be updated like the sentence I mentioned and other definitions like this one:
Presumably that needs to be updated to include triggers too? This is a pretty fundamental change to the whole timing hierarchy so we need to be careful about it. I wonder if it would be better to introduce an abstract concept that covers both animations and animation triggers like "timeline subscribers" or somesuch. |
I opened an issue with a rough proposal here.
I missed that part, I guess I could add that in. Regarding additional APIs, like getting all triggers from document, I guess we could always add these later on demand?
I checked everything and didn't find anything else. I think since triggers only affect playback state and are associated with a timeline, it should be enough to check/update their state according to the timeline, since the trigger's spec describes what to do on state change.
Agreed. I tried simplifying it on the last change. |
Sorry if I created some confusion here. I was mostly getting at that the concepts that need updating are in the web-animations-1 spec, but of course additions to the spec should go in web-animations-2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay on the review. Thanks for putting this together!
Canonical order: per grammar | ||
</pre> | ||
|
||
<span class=prod><dfn><single-animation-trigger-type></dfn> = once | repeat | alternate | state</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a description of what each property value means. Also we probably need a none value on this property to represent the default case right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was pondering all the none
/normal
/auto
options, and I think we currently don't need them, since the initial value is once
, with a timeline value of auto
, which I think is exactly what we have today.
We could also add an issue on that, in case it needs an approval from the group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The definition of the values is done here.
Should I add here another description? More user/less implementor facing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was pondering all the none/normal/auto options, and I think we currently don't need them, since the initial value is once, with a timeline value of auto, which I think is exactly what we have today.
Yeah, I like having the default values basically explain the triggering behavior we get today and adding the ability to modify it. It makes it feel like less of an added on property and more just part of the standard animation infrastructure.
We could also add an issue on that, in case it needs an approval from the group.
I think this can be part of the general review when it's all written up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a description of what each property value means.
Done
Animation Type: not animatable | ||
</pre> | ||
|
||
Issue: Probably a trigger with timeline "none" is under-specified here. Need to clarify what it means. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the default timeline is the document timeline set up in a way such that the "trigger" is always active explaining the normal behavior of animations? You could imagine then using this as a way to coordinate starting an animation after some length of time, e.g. animation-trigger-range: 10s
. Admittedly this has some overlap with animation-delay, but unlike animation delay could use absolute times since page load or other events I suppose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I remember we considered this in a previous issue specifically on syncing animations, but we said there that this will be the stuff that will eventually be done via GroupEffects. That said, if you see some way of changing the definition here and keeping this more open for later extensions I'm all for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but unlike animation delay could use absolute times since page load or other events I suppose?
I feel like we'll still the pseudo-selector you suggested in #8175, for example, to defer until DOM and assets are loaded. This is pretty common.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove the none state, I'm not sure what it even means and the initial value is auto so it's not clear what you'd use none for. With the initial value auto, as you've said it has the same meaning as values of animation-timeline and as such would map to the document timeline. I think we should try to go with this model as it explains the existing behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but none
here is part of the single-animation-timeline
syntax. Should we remove it just here? Or entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.. I suppose suppose we can keep it and I guess the animation would never start?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess it resets state back to idle
.
web-animations-1/Overview.bs
Outdated
@@ -772,6 +772,9 @@ Animation Frames {#animation-frame-loop} | |||
* Updating the [=animation/current time=] of any [=animations=] | |||
[=associated with a timeline|associated with=] the timeline. | |||
|
|||
* Updating the [=animation trigger state=] of any [=animation trigger=] | |||
[=associated with a timeline|associated with=] the timeline. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can move to web-animations-2 right? Also I think this needs to happen before updating the times of animations so that we can set their start time and know to make their effects active if they've been triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the animation-frame-loop
definition exists only here, and I had to only add this one bullet. So what would be the proper way to add it to web-animations-2? Should I add just this delta somehow? Another way?
Regarding order, yes, I'll pull it up to happen before updating animations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we'd add a delta for this section to the ewb-animations-2 spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
web-animations-2/Overview.bs
Outdated
<dl class=switch> | ||
: If |trigger|’s [=local time=] is [=unresolved=], | ||
:: | ||
Then |state| is ''animation trigger state/idle'', and |did trigger| is set to false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't setting did trigger
to false this reset once
triggers anytime the timeline goes idle (e.g. anytime a ScrollTimeline's scroller becomes large enough that it doesn't scroll)? I think this is probably unexpected.
Note, it doesn't look like these links, e.g. ''animation trigger state/idle''
have linked to the definitions correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! I'm not sure whether this is unexpected. I guess we should open another issue for that.
Regarding the links, I'll check and fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't setting did trigger to false this reset once triggers anytime the timeline goes idle (e.g. anytime a ScrollTimeline's scroller becomes large enough that it doesn't scroll)? I think this is probably unexpected.
Gave this another thought. I think this should be expected, but definitely worth opening an issue and discuss this explicitly.
Note, it doesn't look like these links, e.g. ''animation trigger state/idle'' have linked to the definitions correctly.
Right, appears as though these aren't linked correctly, but I used the suggested syntax, so not sure what to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On re-reading this, I realized the did trigger
flag actually says nothing about whether it will retrigger once
animations, and the text the definition for once
says:
The animation is triggered and played once and only once.
Which implies that once animations are not retriggered by this, which I think addresses my primary concern.
I was thinking about whether resizing the scroller / browser such that the area is no longer scrollable should be treated differently than exiting the exit range? My thinking is it shouldn't be any different. You by definition can't be in the exit range. With this in mind I'm not exactly sure what did trigger is trying to accomplish other than perhaps giving different behavior to being outside the active range to start, and going inactive. If this is the case, I think we should just consider the previous state rather than introduce this did trigger variable. E.g. if you're outside the active range and you have no previous state or your previous state was idle, you're still idle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The did trigger
flag is used to differentiate between the initial idle state and the rest of the primary/inverse states going in/out of active interval. Mostly because you always want the initial state to be a non-triggered animation and the rest can be anything else defined by type: running/paused, played/reversed, etc.
I think it's OK for it to be reset on cases like timeline becoming inactive or if setting to a new trigger.
So not sure whether the once and only once
is actually called for.
web-animations-2/Overview.bs
Outdated
|
||
### Animation Trigger Ranges ### {#trigger-ranges} | ||
|
||
An [=animation trigger=] has at least one [=animation attachment range|range=], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should define a new term for the trigger interval's active range, as the combination of the two ranges would probably be worth eventually having a diagram to illustrate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'll try adding that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
web-animations-2/Overview.bs
Outdated
|
||
The ''inverse'' behavior is [=reverse an animation|reversing=] the associated animation. | ||
|
||
<dt><dfn>state</dfn> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if something like play-pause would be clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's another option. The idea behind state
was a reference to play-state
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I could see play-state as an alternative. State feels too strange, I didn't have any idea what this meant until I read the description :-).
Moved the delta of animation-frame-loop from web-animations-1 to web-animations-2
@flackr finished addressing all comments from last review |
…gger state procedure
The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I6ac50730653e70219775895c315f91f771ea7c13
The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I6ac50730653e70219775895c315f91f771ea7c13 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6182723 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1409620}
The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I6ac50730653e70219775895c315f91f771ea7c13 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6182723 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1409620}
The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I6ac50730653e70219775895c315f91f771ea7c13 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6182723 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1409620}
The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I2c335d6be7b6e264fb1cbf4ae4cc3fa9aedc9136
The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I2c335d6be7b6e264fb1cbf4ae4cc3fa9aedc9136
The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I2c335d6be7b6e264fb1cbf4ae4cc3fa9aedc9136 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6187119 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: David Awogbemila <[email protected]> Cr-Commit-Position: refs/heads/main@{#1409968}
The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I2c335d6be7b6e264fb1cbf4ae4cc3fa9aedc9136 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6187119 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: David Awogbemila <[email protected]> Cr-Commit-Position: refs/heads/main@{#1409968}
The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I2c335d6be7b6e264fb1cbf4ae4cc3fa9aedc9136 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6187119 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: David Awogbemila <[email protected]> Cr-Commit-Position: refs/heads/main@{#1409968}
Added AnimationTrigger to Animation, Animatable mixin, and KeyframeAnimationOptions interfaces
@flackr just pushed fixes for the last round of reviews, I think it's ready for another check. |
: Otherwise, | ||
:: | ||
The ''primary'' behavior is [=reverse an animation|reversing=] the associated animation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little curious about how this works. Am I correct that for animation-trigger-type: alternate
the animation should be played when entering the animation-trigger-range
and reversed when exiting the animation-trigger-exit-range
? If so, it seems like the behavior defined for alternate
here could result in reversing the animation while we're inside the exit range?
Let me try to use an example and perhaps you can point out what I've misunderstood. Say we have:
ainmation-trigger: view() alternate cover 0% cover 100%;
and lets say cover 0% and cover 100% correspond to 100px and 200px respectively.
So the default range and the exit range are both [100, 200].
The page loads, scrollTop
= 0, the trigger's state is idle
(active interval is [100,200]).
Then we scroll to 150px, so we set the trigger's state to primary
(the active interval is now the exit range, still [100, 200]. since did trigger
is false we play the animation) and set did trigger
to true.
We then scroll to 160px and the animation trigger's state is updated: since we are still inside the active interval,
we set the state to primary
(since did trigger
is true, we reverse the animation) and set did trigger
to true.
So we would have reversed the animation despite not having exited the exit range?
Or perhaps I'm not quite correct about when the animation trigger gets updated?
It seems like we don't need the if/else and the alternate
behavior should just be primary
->trigger
, inverse
->reverse
?
I might also have missed something about did trigger
... it seems the algorithm is given a flag did trigger
, but also defines a did trigger
var, and the animation trigger also has an internal did trigger
, so maybe I should clarify how those are related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this one is a bit tricky. The idea is that if did trigger
is false then we play "forwards". Then, on every state change we reverse. The problem, as you described it, is that state change will occur on every scroll change. But my internet was that a state change occurs only when the active attachment range is either entered or exited.
So the way I intend for it behave is to not change state until the range is exited. Then reverse on exit, and reverse back on re-enter, and so on
Does this make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might not be totally clear on the last line:
Then reverse on exit, and reverse back on re-enter, and so on
I understand that we would reverse the animation on exit (exiting the exit range), but on re-enter (re-entering the trigger range) we would just play the animation forwards again right? is this what you mean by "reverse back"?
If that's right, what do you think about simplifying the primary
behavior for alternate
? I think that simply having:
'alternate'
The primary behavior is triggering the associated animation. The inverse behavior is reversing the associated animation.
fixes the issue of reversing on every scroll?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that we would reverse the animation on exit (exiting the exit range), but on re-enter (re-entering the trigger range) we would just play the animation forwards again right? is this what you mean by "reverse back"?
What I mean is that after reversing an animation its effective playback rate remains inveresed, so you'll first need to inverse the playback rate, and then invoke the play an animation procedure, which is exactly the reversing an animation procedure.
fixes the issue of reversing on every scroll?
My issue with "every scroll" is that I'd just like to clarify that we don't do anything on every scroll change. Even though we're using Scroll and View timelines here, the changes are singular on range entry/exit, and don't occur repeatedly on progress change, like SDA's do. Otherwise we would need to re-trigger primary
on each scroll change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the "reverse" on re-enter is the forwards direction, however, it is worth noting that it might not start from the beginning of the animation if the reverse animation hadn't finished. E.g. if you temporarily move out of the exit range and then back into the trigger range you may only play from backwards from 100% back to 80%, then reverse back to 100%.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, of course. This is the precise intent, just like flipping a transition mid-way.
1. Set |state| to ''animation trigger state/primary''. | ||
1. Set |did trigger| to true. | ||
|
||
: Otherwise, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to my comment above, would we have an issue if we have non-overlapping trigger and exit ranges? One use case I can think of for non-overlapping ranges is if you wanted a repeat
trigger but in only one scrolling direction. E.g. you only want the animation to trigger scrolling downwards (item translates upwards into view). In this case you'd define the exit range and the default range as, e.g. [0, 100] and [150, infinity] so you can only reset the animation by scrolling back up by a sufficient amount. As currently written it looks like this algorithm will probably reset the animation shortly after we trigger it:
- enter the trigger range, e.g. 160px
-
- plays the animation, state becomes
primary
-> exit range [0, 100] becomes active interval
- plays the animation, state becomes
- further scrolling (still outside exit range, e.g. 170px)
-
- animation is reset.
?
- animation is reset.
One way we could address this would be to define two types of (active) intervals, an entry interval
and an exit interval
and have the trigger keep track of whether, at the last update it was within the interval within active interval
defaulting to false. Then the algorithm can decide whether to apply the primary
or inverse
behavior based on whether we are entering or exiting the relevant interval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused here.
Let's first see we're on the same page about the exit range:
Once the user is inside the default range, and primary
behavior is triggered, the active range is immediately switched to the exit range. And only once you exit that range, the state switches again.
If we allow exit ranges that are "smaller" then their corresponding default ranges then we could be allowing endless loops or other weird behaviors. So I suggested as an issue in the PR to perhaps restrict exit ranges to only be equal or larger than default ranges, and that they can not constrict them, see here.
I can't think now about any interesting effect one could do with a non-overlapping exit range, so I suggest avoiding it, just like we enforce range start is not larger than range end, or the timeline becomes inactive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thanks for adding that as an issue in the spec. I guess it (restricting valid values of the exit range to be "equal to or greater than" the trigger range) is something the working group will want to consider and we can file an issue for it after this PR has landed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think to make things simple we may just want to spec that being in the trigger range also counts as being in the exit range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, they both define the active range. I'm not following. Could you be more specific technically what would that mean in the spec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think to make things simple we may just want to spec that being in the trigger range also counts as being in the exit range.
Hmm, could you elaborate? I'm not sure that will fully address the concern about how the current PR will handle non-overlapping ranges, particularly if I changed the entry range from [150, infinity] to [150, 200] and scrolling beyond 200px is possible (ignoring that that now makes it possible to trigger the animation by scrolling either up or down).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think to make things simple we may just want to spec that being in the trigger range also counts as being in the exit range.
Hmm, could you elaborate? I'm not sure that will fully address the concern about how the current PR will handle non-overlapping ranges, particularly if I changed the entry range from [150, infinity] to [150, 200] and scrolling beyond 200px is possible (ignoring that that now makes it possible to trigger the animation by scrolling either up or down).
Ah.. but maybe it's not such a valid use case anymore if you shrink the entry range - you can trigger it scrolling up or down, but you can only reset it scrolling up far enough and then scrolling down again :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ydaniv I haven't re-reviewed the specific algorithm, but the idea is we wouldn't enter the state/inverse state if you're in the primary trigger range - which means it doesn't matter if your exit range is defined to be inclusive of it or not, the entry range is by definition part of it.
…range-*, a=testonly Automatic update from web-platform-tests Implement parsing for animation-trigger-range-* The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I6ac50730653e70219775895c315f91f771ea7c13 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6182723 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1409620} -- wpt-commits: 78c349f14e31d5bbba8a109e1529ee7cb94dd0bf wpt-pr: 50216
…{exit-}range shorthands, a=testonly Automatic update from web-platform-tests Implement parsing for animation-trigger-{exit-}range shorthands The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I2c335d6be7b6e264fb1cbf4ae4cc3fa9aedc9136 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6187119 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: David Awogbemila <[email protected]> Cr-Commit-Position: refs/heads/main@{#1409968} -- wpt-commits: eb78c18f83a97a696c4293facc05c7b877b49fd6 wpt-pr: 50225
…range-*, a=testonly Automatic update from web-platform-tests Implement parsing for animation-trigger-range-* The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I6ac50730653e70219775895c315f91f771ea7c13 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6182723 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1409620} -- wpt-commits: 78c349f14e31d5bbba8a109e1529ee7cb94dd0bf wpt-pr: 50216
…{exit-}range shorthands, a=testonly Automatic update from web-platform-tests Implement parsing for animation-trigger-{exit-}range shorthands The spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I2c335d6be7b6e264fb1cbf4ae4cc3fa9aedc9136 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6187119 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: David Awogbemila <[email protected]> Cr-Commit-Position: refs/heads/main@{#1409968} -- wpt-commits: eb78c18f83a97a696c4293facc05c7b877b49fd6 wpt-pr: 50225
web-animations-2/Overview.bs
Outdated
1. Set |state| as follows: | ||
<dl class=switch> | ||
: If |trigger|’s [=local time=] is [=unresolved=], | ||
:: | ||
1. Set |state| to ''animation trigger state/idle''. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to count this as not being inside the trigger range, i.e. switching to state/inverse if we've triggered? It might be a bit odd that you stay in the triggered state when the timeline is inactive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is looking good. There are still a few details to work out but overall I think the general algorithm should work pretty well and I don't want to delay getting the initial spec in :-)
For reference: the spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I3b273f4565efddd2fd48d407102f9f1376d816dd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6207949 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1414034}
For reference: the spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I3b273f4565efddd2fd48d407102f9f1376d816dd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6207949 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1414034}
For reference: the spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I3b273f4565efddd2fd48d407102f9f1376d816dd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6207949 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1414034}
…tonly Automatic update from web-platform-tests Parse animation-trigger shorthand For reference: the spec is currently a work-in-progress[1] but this comment[2] describes the API. [1] w3c/csswg-drafts#10128 [2] w3c/csswg-drafts#8942 (comment) Bug: 390314945 Change-Id: I3b273f4565efddd2fd48d407102f9f1376d816dd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6207949 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1414034} -- wpt-commits: 52bce37bd96221c1fc5a60da383faef154724895 wpt-pr: 50409
Adding initial draft for Animation Triggers and the
animation-trigger
property as resolved in #8942 (comment).I cleared all the issues and fleshed out the gist of it.
cc @flackr @birtles @dbaron