|
1 | 1 | [](https://circleci.com/gh/stipsan/smooth-scroll-into-view-if-needed)
|
2 | 2 | [](https://npm-stat.com/charts.html?package=smooth-scroll-into-view-if-needed)
|
3 | 3 | [](https://www.npmjs.com/package/smooth-scroll-into-view-if-needed)
|
| 4 | +[![gzip size][gzip-badge]][unpkg-dist] |
| 5 | +[![size][size-badge]][unpkg-dist] |
| 6 | +[![module formats: umd, cjs, and es][module-formats-badge]][unpkg-dist] |
4 | 7 | [](https://github.com/semantic-release/semantic-release)
|
5 | 8 | 
|
6 | 9 |
|
7 | 10 | This is an addon to [`scroll-into-view-if-needed`](https://www.npmjs.com/package/scroll-into-view-if-needed) that [ponyfills](https://ponyfill.com) smooth scrolling.
|
8 | 11 |
|
9 | 12 | ### This package requires v2 of `scroll-into-view-if-needed`, currently in prerelease
|
10 | 13 |
|
11 |
| - |
12 | 14 | ## [Demo](https://scroll-into-view-if-needed.netlify.com/)
|
13 | 15 |
|
14 | 16 | ## Install
|
@@ -44,30 +46,9 @@ const sequence = async () => {
|
44 | 46 | }
|
45 | 47 | ```
|
46 | 48 |
|
47 |
| -### Custom scrolling transition |
48 |
| - |
49 |
| -If the default smooth scrolling ponyfill isn't the duration or easing you want, |
50 |
| -you can provide your own scrolling logic by giving `behavior` a callback (this is actually a `scroll-into-view-if-needed` feature, if this is what you're after then you might need this package). |
51 |
| - |
52 |
| -```js |
53 |
| -import scrollIntoView from 'smooth-scroll-into-view-if-needed' |
54 |
| -const node = document.getElementById('hero') |
55 |
| - |
56 |
| -scrollIntoView(node, { |
57 |
| - // Your scroll actions will always be an array, even if there is nothing to scroll |
58 |
| - behavior: actions => |
59 |
| - // list is sorted from innermost (closest parent to your target) to outermost (often the document.body or viewport) |
60 |
| - actions.forEach(({ el, top, left }) => { |
61 |
| - // implement the scroll anyway you want |
62 |
| - el.scrollTop = top |
63 |
| - el.scrollLeft = left |
64 |
| - |
65 |
| - // If you need the relative scroll coordinates, for things like window.scrollBy style logic, just do the math |
66 |
| - const offsetTop = el.scrollTop - top |
67 |
| - const offsetLeft = el.scrollLeft - left |
68 |
| - }), |
69 |
| - // all the other options (scrollMode, block, inline) still work, so you don't need to reimplement them (unless you really really want to) |
70 |
| -}) |
71 |
| -``` |
| 49 | +## More documentation will be added |
72 | 50 |
|
73 |
| -## More documentation will be added (hang in there) |
| 51 | +[gzip-badge]: http://img.badgesize.io/https://unpkg.com/smooth-scroll-into-view-if-needed/umd/smooth-scroll-into-view-if-needed.min.js?compression=gzip&label=gzip%20size&style=flat-square |
| 52 | +[size-badge]: http://img.badgesize.io/https://unpkg.com/smooth-scroll-into-view-if-needed/umd/smooth-scroll-into-view-if-needed.min.js?label=size&style=flat-square |
| 53 | +[unpkg-dist]: https://unpkg.com/smooth-scroll-into-view-if-needed/umd/ |
| 54 | +[module-formats-badge]: https://img.shields.io/badge/module%20formats-umd%2C%20cjs%2C%20es-green.svg?style=flat-square |
0 commit comments