Open majido opened 6 years ago
This is interesting. So if I understand this correctly, basically the navigation element becomes highlighted when their respective page is scrolled into view.
This is definitely something we like to ensure it is possible to build with AnimationWorklet + ScrollTimeline. In fact it is a key usecase mentioned for ScrcollTimeline but based on the information in that specification they have punted on addressing it for now.
I suspect we need the following things in place:
.active
class and that way you can specify any transition. A straightforward way to do this is to just have a keyframe effect that models the transition for specific style properties. This is not as flexible as adding a class but practical.So I feel all the right ingredients to make something like this are already present in current AnimationWorklet proposal 👍.
In such an implementation, the worklet animation is only used for providing "trigger" behavior. There has been some consideration to add such a feature to ScrollTimeline itself as well to make such a thing even easier.
@flackr FYI.
I suggest adding this type of scroll-triggered navigation under "Scroll-linked effects". I don't particularly think it needs to require a "css transition".
From @Malvoz on February 23, 2018 1:16
Could the "scrollspy"-pattern be included as a motivating use case?
Demos: https://getbootstrap.com/docs/4.0/components/scrollspy/ https://scotch.io/tutorials/build-a-custom-javascript-scrollspy-navigation
Copied from original issue: WICG/animation-worklet#92