-
Notifications
You must be signed in to change notification settings - Fork 666
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
[scroll-animations-1] CSS @scroll-timeline: Allow <element-offset>
selector() to point to self
#5884
Comments
Afternoon idea: a value of |
This is crucial for the proposal to succeed. Building one Problem: Multiple choreographed animations In the example this is solved by having a In the real world one page would contain many similar "scrollable picture stories", often user/author generated. We don't build unique selectors for component instances, and we should not have to build unique timelines for component instances. (For an example of a page with multiple animated picture-stories check the yellow dotted lines here: https://www.nrk.no/norge/xl/pa-innsiden-av-hagens-hus-1.15206175) Referencing the animated element (self) This solves part of the problem. But for multiple element animations to be coordinated, it is necessary to reference a common parent of the animated elements. In the "scrollable picture story" the circles might not be placed in the same location, and if the timeline reference each individual animated element, they will end up with different timelines. The choreography will break. Referencing a common parent We could do this using the relational pseudo-class:
A simplified version of the extended use case could then be solved as follows:
|
I'm not sure if I don't have a better suggestion though. |
As I came to understand on Twitter per tweet by @majido (ref):
In the linked-to issue #4337 this is covered in more detail, and the (initially) proposed keyword is
|
Idea: what if That would:
|
Closing this issues as the spec is being rewritten to not use |
When animating an element based on the location of the element itself inside a scroll container using scroll-animations, you need to set a
start
andend
. To configure this one needs an Element-based Offset.When applying such an animation using the JavaScript it's pretty easy to set this up for many elements, as you can use a loop and refer to the current element by referring to its local var. See
startScrollOffset
/endScrollOffset
in the code snippet below.While trying to recreate this using the CSS @scroll-timeline I've noticed that this this type of concise code is exactly possible as the
<element-offset>
type requires aselector(<id-selector>)
. Because of that one has to create @scroll-timeline's for every individualli
To not have to repeat that @scroll-timeline definition over and over again for each and every single
li
, it'd be handy if theselector()
part in the<element-offset>
could be configured in such a way that it refers to the element being animated itself, e.g.this
orself
.That way our code would become something like this:
I see this as a huge benefit to the spec, as this would open up the way for animation/code reuse.
Would this be something worth pursuing, or am I overlooking something in the spec that would already allow this?
The text was updated successfully, but these errors were encountered: