scroll-to-anchor

Scroll to the current anchor in the url if possible

MIT 2 个版本
安装
npm install scroll-to-anchor
yarn add scroll-to-anchor
pnpm add scroll-to-anchor
bun add scroll-to-anchor
README

scroll-to-anchor stability

npm version build status downloads js-standard-style

Scroll to an anchor if possible.

Usage

var scrollToAnchor = require('scroll-to-anchor')
scrollToAnchor(window.location.hash)
scrollToAnchor(window.location.hash, { behavior: 'smooth' })

API

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 method which allows for more positioning options and scroll behaviour changes.

License

MIT

版本列表
1.1.0 2017-06-18
1.0.0 2017-06-17