smooth-scroll-anchor
TypeScript icon, indicating that this package has built-in type declarations

1.2.5 • Public • Published

Smooth Scroll Anchor

Automatically scroll to any given anchor links.

Install

npm i --save smooth-scroll-anchor

Use

import { smoothScrollAnchor } from "smooth-scroll-anchor";
smoothScrollAnchor();

Markup

<a href="#target">Click to scroll</a>
<div id="target">Target element</div>

Options

A few cheeky lil' things can be configured like so:

smoothScrollAnchor({
  behaviour: "smooth", // [smooth | auto] Smooth animated scroll or instant
  block: "center", // [start | center | end | nearest] Alignment of the target element when it's finished scrolling
  offset: 200 // Optional offset of the target scroll position. Handy if you have a fixed header!
});

Support

IE11+, Edge (via polyfill) and all modern browsers (native functionality)

Readme

Keywords

Package Sidebar

Install

npm i smooth-scroll-anchor

Weekly Downloads

81

Version

1.2.5

License

ISC

Unpacked Size

12 kB

Total Files

6

Last publish

Collaborators

  • entozoon