[css-scroll-snap] Proposing `:snapped`: exposing private snapped item browser state for developers and designers
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
Currently, IntersectionObserver and or hacks (like making gap 100vmin in a frame so JS can check to see which element is still within the viewport..) are ways to try and derive this, but it's not usually performant, timed properly or accurate. This proposal seeks to remove the hacks and inaccurate algorithms. The browser has an item target it snapped to, developers should have access to that element.
For example, it's nice to outline the snapped element to help reinforce the state of the scroller:
:snapped-inline {
outline: 3px solid hotpink;
}
or to lift a snapped header when snapped:
section:snapped-y > header {
box-shadow: 0 .5em 1em .5em lch(5% 5% 200);
}
There's a lot more use cases and details about the proposal (cyclical resolution, full set of pseudo selectors, etc) in the Explainer
Related: #5979
Would love to present the details of the explainer to the CSSWG for feedback 🙂
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked css-snap-target explainer, then review the related issue #5979 and the discussion here. Focus on the proposed pseudo-selectors, cyclical resolution, and use cases; done means the proposal has received CSSWG feedback on these details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100