🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

scroll-to-anchor

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll-to-anchor - npm Package Compare versions

Comparing version

to
1.1.0

4

index.js
module.exports = scrollToAnchor
function scrollToAnchor (anchor) {
function scrollToAnchor (anchor, options) {
if (anchor) {
try {
var el = document.querySelector(anchor)
if (el) el.scrollIntoView(true)
if (el) el.scrollIntoView(options)
} catch (e) {}
}
}

@@ -5,3 +5,3 @@ {

"repository": "yoshuawuyts/scroll-to-anchor",
"version": "1.0.0",
"version": "1.1.0",
"scripts": {

@@ -8,0 +8,0 @@ "deps": "dependency-check . && dependency-check . --extra --no-dev",

@@ -11,9 +11,12 @@ # scroll-to-anchor [![stability][0]][1]

scrollToAnchor(window.location.hash)
scrollToAnchor(window.location.hash, { behavior: 'smooth' })
```
## API
### `scrollToAnchor(anchor)`
### `scrollToAnchor(anchor, options)`
Scroll to an anchor if possible. Does nothing if no anchor is provided or if the
anchor doesn't exist on the page.
You can also specify the same options as the [scrollIntoView](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView#Parameters) method which allows for more positioning options and scroll behaviour changes.
## License

@@ -20,0 +23,0 @@ [MIT](https://tldrlegal.com/license/mit-license)