Skip to content

[css-overflow][css-scroll-snap] Introduce mechanism to extend scrollable overflow area to make snap points reachable #7885

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

Open
johannesodland opened this issue Oct 15, 2022 · 4 comments
Labels
Agenda+ Later Lower-priority items that are flagged for CSSWG discussion css-overflow-4 css-scroll-snap-1 Current Work css-scroll-snap-2

Comments

@johannesodland
Copy link

johannesodland commented Oct 15, 2022

Problem

It is possible to define unreachable snap points. The used snap position will then be the position resulting from scrolling as much as possible towards the snap position.

But, in many components, such as galleries and carousels, you want the user to be able to reach those snap points.

Current solution

The current solution is to add padding, or ::before and ::after pseudo elements to increase the scrollable overflow area so that the snap points can be reached.

It is not always possible to use CSS to exactly match the needed area. It is often necessary to use JS to calculate this area so that the scroll container can be scrolled exactly to the snap points, but not further.

To be able to build pure CSS scroll snap components, we need a way to be able to extend the scrollable overflow area so that all snap points can be reached.

Proposal

Add a property to control the scrollable overflow area.

scrollable-overflow-area: [ normal | include-snap-points ]

(Names up for bikeshedding.)

<div class=gallery>
  <img ...><img ...><img ...>
</div>
.gallery {
  scroll-snap-type: inline mandatory; 
  scrollable-overflow-area: include-snap-points;
}

.gallery img {
  scroll-snap-align: center;
}

Alternatives

  • Extend padding properties with a keyword to extend padding enough to make snap points reachable.
  • Expose the necessary sizes as values that can be used to size padding or ::before and ::after elements.
@johannesodland johannesodland changed the title [css-overflow][css-scroll-snap] Introduce mechanism to include snap points in scrollable overflow area [css-overflow][css-scroll-snap] Introduce mechanism to extend scrollable overflow area to make snap points reachable Oct 15, 2022
@fantasai
Copy link
Collaborator

@majido What do you think about this idea?

@johannesodland
Copy link
Author

Such a property could be used to control the scrollable overflow area in more ways:

scrollable-overflow-area: normal | include-snap-points || include-padding || include-negative

(Names up for bikeshedding.)

include-padding
Include the end-side padding

include-negative
Include boxes outside block-start or inline-start padding edges, that are otherwise discarded.

include-snap-points and include-negative would possibly interact with the scroll-an-element algorithm, otherwise the negative scroll area would not be reachable.

@fantasai
Copy link
Collaborator

Note, we already are including end-side padding, see #129

Allowing for negative positioning as well seems pretty interesting.

Some possible bikeshedding:

scroll-area: normal | include-negative || include-snap

or

scroll-contain: normal | negative || snap

@fantasai fantasai added the Agenda+ Later Lower-priority items that are flagged for CSSWG discussion label Dec 30, 2022
@johannesodland
Copy link
Author

Note, we already are including end-side padding, see #129

Nice! I didn't realize that the issue had been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agenda+ Later Lower-priority items that are flagged for CSSWG discussion css-overflow-4 css-scroll-snap-1 Current Work css-scroll-snap-2
Projects
Status: Unslotted
Development

No branches or pull requests

2 participants