smooth-scroll-into-view-if-needed
Advanced tools
Comparing version 1.0.1-alpha.3 to 1.0.1-alpha.4
@@ -11,6 +11,7 @@ { | ||
}, | ||
"version": "1.0.1-alpha.3", | ||
"version": "1.0.1-alpha.4", | ||
"main": "index.js", | ||
"files": [ | ||
"es", | ||
"typings", | ||
"umd" | ||
@@ -32,3 +33,3 @@ ], | ||
}, | ||
"dependencies": { | ||
"peerDependencies": { | ||
"scroll-into-view-if-needed": "^2.0.1-alpha.0" | ||
@@ -63,2 +64,3 @@ }, | ||
"rollup-plugin-uglify": "3.0.0", | ||
"scroll-into-view-if-needed": "^2.0.1-alpha.0", | ||
"semantic-release": "15.1.7", | ||
@@ -65,0 +67,0 @@ "semantic-release-monorepo": "6.0.1", |
@@ -7,4 +7,4 @@ [![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) | ||
This is a [ponyfill](https://ponyfill.com) for smooth scrolling | ||
`scroll-into-view-if-needed`. | ||
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. | ||
. | ||
@@ -16,3 +16,3 @@ ## [Demo](https://scroll-into-view-if-needed.netlify.com/) | ||
```bash | ||
yarn add smooth-scroll-into-view-if-needed | ||
yarn add smooth-scroll-into-view-if-needed scroll-into-view-if-needed | ||
``` | ||
@@ -50,3 +50,3 @@ | ||
If the default smooth scrolling ponyfill isn't the duration or easing you want, | ||
you can provide your own scrolling logic by giving `behavior` a callback. | ||
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). | ||
@@ -59,12 +59,12 @@ ```js | ||
// Your scroll actions will always be an array, even if there is nothing to scroll | ||
behavior: scrollActions => | ||
behavior: actions => | ||
// list is sorted from innermost (closest parent to your target) to outermost (often the document.body or viewport) | ||
scrollActions.forEach(([el, scrollTop, scrollLeft]) => { | ||
scrollActions.forEach(({ el, top, left }) => { | ||
// implement the scroll anyway you want | ||
el.scrollTop = scrollTop | ||
el.scrollLeft = scrollLeft | ||
el.scrollTop = top | ||
el.scrollLeft = left | ||
// If you need the relative scroll coordinates, for things like window.scrollBy style logic, just do the math | ||
const offsetTop = el.scrollTop - scrollTop | ||
const offsetLeft = el.scrollLeft - scrollLeft | ||
const offsetTop = el.scrollTop - top | ||
const offsetLeft = el.scrollLeft - left | ||
}), | ||
@@ -71,0 +71,0 @@ // all the other options (scrollMode, block, inline) still work, so you don't need to reimplement them (unless you really really want to) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41808
10
746
30