argyleink / argyleink/ScrollSnapExplainers

[js-snapTo()] Define which node will be selected for string arguments.

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
104
Forks
3
PR merge metrics
No merged PRs in 30d

Description

[snapTo](https://github.com/argyleink/ScrollSnapExplainers/blob/main/js-snapTo%28%29/explainer.md#snaptoaxis-string--node) accepts a string argument which can be one of next, prev, first, last, however doesn't explain what these mean. I believe that there are many complicated cases where it's not clear which is next / last or prev / first.

For example, consider the following:
```html

.scroller {
overflow: auto;
width: 50px;
height: 50px;
position: relative;
scroll-snap-type: both mandatory;
}

.scroller div {
position: absolute;
background: yellow;
border: 5px solid black;
scroll-snap-align: center;
}

.a {
left: 200px;
top: 40px;
}

.b {
left: 40px;
top: 200px;
}

.c {
left: 20px;
top: 60px;
}

.d {
left: 80px;
top: 20px;
}


A

B

C

D


```

What is the first snap point? Is it:
- A because A is first in DOM order?
- C because C is the nearest to the initial scroll?
- D because D is first in block order?
Additionally, does first depend on which axis is specified? What if none of the snap points snap on both axes? (e.g. they are a mix of `scroll-snap-align: center none` and `scroll-snap-align: none center`

What is the next snap point? Next implies that it is based on the current snap point but it is possible (currently) to be snapped to one node in one axis and a different node in the other axis.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read the snapTo(string | node) section in js-snapTo()/explainer.md, especially the linked anchor and the provided multi-axis example. Work out and document how first, last, next, and prev select nodes across axes and mixed snap alignments. Done means the string arguments have unambiguous definitions that address the listed cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
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.