w3c / w3c/csswg-drafts

[css-scroll-snap] making proximity snapping more customizable

Open
#4,802 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-scroll-snap-2
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

It was suggested to me that it will be useful to make proximity more configurable.
At the moment the interpretation of proximity is left to the UA (See here). For example Chrome implementation is simple that it snaps if the snap area is within a fixed distance of the appropriate snap alignment (30% of scroller size in that axis).

I think we should consider providing customizability for scroll snap to the developers. This would be valuable for some type of content where it is desirable to snap only if the content is very close to the edge of the scroller.

API Ideas

Here are few APIs ideas that we can explore:

  1. Make proximity a css function e.g., scroll-snap-type: proximity(50px) or even allow a margin like 2/4-value syntax scroll-snap-type: proximity(10% 20%)

  2. Introduce a new property scroll-snap-proximity-hint: 50px. This can be done either on snap area or container (or both?)

Some interesting discussions to have:

  • Do we need to have this control per snap area or having it at the scrollcontainer is enough? At the moment, I think having it per container is sufficient but happy to re-consider.
  • Should this be a hint to UA algorithm or do we want a more precise definition? I am curious if other UA engines are doing anything more sophisticated for proximity calculation. If all engines are doing a simple distance check perhaps we should specify this which has the advantage of interoperability and predictability for authors.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CSS Scroll Snap specification section linked in the issue, then review the proposed proximity function and new property ideas. Compare how user agents currently determine proximity, as suggested by the issue, and document a resolved API and behavior proposal before attempting an implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.