Skip to content
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-scroll-snap] making proximity snapping more customizable #4802

Open
majido opened this issue Feb 24, 2020 · 3 comments
Open

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

majido opened this issue Feb 24, 2020 · 3 comments

Comments

@majido
Copy link
Contributor

majido commented Feb 24, 2020

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.
@majido majido added the css-scroll-snap-1 Current Work label Feb 24, 2020
@tabatkins
Copy link
Member

We avoided this in the initial design because (1) it seemed relatively low-value, and (2) it's valuable for features like scrolling to feel consistent to users across sites.

Can you elaborate on the use-case you see for snapping "only when very close to the edge" vs the default Chrome snapping?

@majido
Copy link
Contributor Author

majido commented Feb 25, 2020

On the feel consistent part, at the moment in Chrome implementation the behavior depends on scroller size so I see exposing it to authors as a big departure. Also note that it also behave differently across UAs.

On the value of the usecase, @ianvollick had a specific usecase in mind. I think he can explain it better.

@ianvollick
Copy link

I was just thinking of scenarios where you want to nudge into position if an element is very close to its final, snapped position, but not impact scrolling, otherwise. I agree that this could make scrolling feel inconsistent.

@fantasai fantasai added css-scroll-snap-2 and removed css-scroll-snap-1 Current Work labels Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants