Skip to content

Commit 82dd1d5

Browse files
authored
Move to peer deps (#2)
1 parent c93b73e commit 82dd1d5

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
[![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)
55
![smooth-scroll-into-view-if-needed](https://user-images.githubusercontent.com/81981/39338604-0bff23f2-49c4-11e8-9929-2f2b74a67b3c.png)
66

7-
This is a [ponyfill](https://ponyfill.com) for smooth scrolling
8-
`scroll-into-view-if-needed`.
7+
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+
.
99

1010
## [Demo](https://scroll-into-view-if-needed.netlify.com/)
1111

1212
## Install
1313

1414
```bash
15-
yarn add smooth-scroll-into-view-if-needed
15+
yarn add smooth-scroll-into-view-if-needed scroll-into-view-if-needed
1616
```
1717

1818
## Usage
@@ -45,24 +45,24 @@ const sequence = async () => {
4545
### Custom scrolling transition
4646

4747
If the default smooth scrolling ponyfill isn't the duration or easing you want,
48-
you can provide your own scrolling logic by giving `behavior` a callback.
48+
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).
4949

5050
```js
5151
import scrollIntoView from 'smooth-scroll-into-view-if-needed'
5252
const node = document.getElementById('hero')
5353

5454
scrollIntoView(node, {
5555
// Your scroll actions will always be an array, even if there is nothing to scroll
56-
behavior: scrollActions =>
56+
behavior: actions =>
5757
// list is sorted from innermost (closest parent to your target) to outermost (often the document.body or viewport)
58-
scrollActions.forEach(([el, scrollTop, scrollLeft]) => {
58+
scrollActions.forEach(({ el, top, left }) => {
5959
// implement the scroll anyway you want
60-
el.scrollTop = scrollTop
61-
el.scrollLeft = scrollLeft
60+
el.scrollTop = top
61+
el.scrollLeft = left
6262

6363
// If you need the relative scroll coordinates, for things like window.scrollBy style logic, just do the math
64-
const offsetTop = el.scrollTop - scrollTop
65-
const offsetLeft = el.scrollLeft - scrollLeft
64+
const offsetTop = el.scrollTop - top
65+
const offsetLeft = el.scrollLeft - left
6666
}),
6767
// all the other options (scrollMode, block, inline) still work, so you don't need to reimplement them (unless you really really want to)
6868
})

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"prepublishOnly": "unset npm_config_cafile && yarn build",
3131
"typecheck": "tsc --noEmit"
3232
},
33-
"dependencies": {
33+
"peerDependencies": {
3434
"scroll-into-view-if-needed": "^2.0.1-alpha.0"
3535
},
3636
"devDependencies": {
@@ -60,6 +60,7 @@
6060
"rollup-plugin-node-resolve": "3.3.0",
6161
"rollup-plugin-replace": "2.0.0",
6262
"rollup-plugin-uglify": "3.0.0",
63+
"scroll-into-view-if-needed": "^2.0.1-alpha.0",
6364
"semantic-release": "15.1.7",
6465
"semantic-release-monorepo": "6.0.1",
6566
"typescript": "2.8.3"

0 commit comments

Comments
 (0)