Skip to content

Commit

Permalink
taps on items in #9
Browse files Browse the repository at this point in the history
  • Loading branch information
argyleink authored Jun 3, 2021
1 parent 6863085 commit 337c0d3
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions js-snapTo()/explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,37 @@ Wiring up "snap to next", "snap to last" or "snap to the clicked item" should be
5. Slides
6. Click/tap and snap to item

> Interestingly, the keyboard already has access to `next` and `previous` via the arrows, or something like it.
<br>

## Proposed Solution

### `snapTo(<axis>, <string | node>)`
### snapTo(`<axis>`, `<string>` or `<node>`)
- `<axis>` accepts
- strings (x | y | inline | block | both)
- `<string | node>` accepts
- strings (next | prev | first | last)
- node
- must be a child of the scroller and a registered snap child of the snapport

### Example 1

Example usage:
```js
scrollSnapContainer.snapTo('x', 'next')
scrollSnapContainer.snapTo('y', 'prev')
scrollSnapContainer.snapTo('x', 'first')
scrollSnapContainer.snapTo('y', 'last')
scrollSnapContainer.snapTo('x', childNode)
scrollSnapContainer.snapTo('x', scrollSnapContainer.querySelector('.child-2'))
```

<br>

### Example 1 `.snapTo('x', 'next')`
The browser should scroll in that direction the same amount as if the `right arrow key` was pressed and perform it's routine regarding proximity and mandatory next snap target discovery.

### Example 2 `.snapTo('inline', 'next')`
If the browser is set to `rtl`, then the browser should scroll left the same amount as if the `left arrow key` was pressed and perform it's routine regarding proximity and mandatory next snap target discovery.

<br>

## Privacy and Security Considerations

### Privacy
Expand Down

0 comments on commit 337c0d3

Please sign in to comment.