Skip to content

Commit 4d86391

Browse files
authored
chore(readme): add badges for size (#9)
1 parent eb605ef commit 4d86391

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

README.md

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
[![CircleCI Status](https://img.shields.io/circleci/project/github/stipsan/smooth-scroll-into-view-if-needed.svg?style=flat-square)](https://circleci.com/gh/stipsan/smooth-scroll-into-view-if-needed)
22
[![npm stat](https://img.shields.io/npm/dm/smooth-scroll-into-view-if-needed.svg?style=flat-square)](https://npm-stat.com/charts.html?package=smooth-scroll-into-view-if-needed)
33
[![npm version](https://img.shields.io/npm/v/smooth-scroll-into-view-if-needed.svg?style=flat-square)](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]
47
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
58
![smooth-scroll-into-view-if-needed](https://user-images.githubusercontent.com/81981/39338604-0bff23f2-49c4-11e8-9929-2f2b74a67b3c.png)
69

710
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.
811

912
### This package requires v2 of `scroll-into-view-if-needed`, currently in prerelease
1013

11-
1214
## [Demo](https://scroll-into-view-if-needed.netlify.com/)
1315

1416
## Install
@@ -44,30 +46,9 @@ const sequence = async () => {
4446
}
4547
```
4648

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
7250

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

Comments
 (0)