Smooth scroll to anchor links
npm install smooth-scroll-anchorAutomatically scroll to any given anchor links.
``console`
npm i --save smooth-scroll-anchor
`ts`
import { smoothScrollAnchor } from "smooth-scroll-anchor";
smoothScrollAnchor();
`html`
Click to scrollTarget element
A few cheeky lil' things can be configured like so:
`ts``
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!
});
IE11+, Edge (via polyfill) and all modern browsers (native functionality)