Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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 1.0.0 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)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc