2.0.1 ā€¢ Published 7 years ago

anchor-scroller v2.0.1

Weekly downloads
42
License
MIT
Repository
github
Last release
7 years ago

anchor-scroller

āš“ļø Smoothly scroll to #anchors

Features

  • ... Scrolls to anchors
  • Stops scrolling if the user scrolls
  • Doesn't try to scroll past the end
  • It's only 1.5kb in size (900 bytes gzipped šŸ˜†)
  • Uses requestAnimationFrame for smooth animation

Quickstart

Node with a module bundler

npm install anchor-scroller --save
const AnchorScroller = require("anchor-scroller");
AnchorScroller();

Browser

<script src="https://unpkg.com/anchor-scroller@2.0.1/distribution/AnchorScroller.js"></script>
<script>AnchorScroller()</script>

Check out the wiki for more info.

Configuration

You can pass the instance an options object to tweak it's behavior. The simplest options are class and checkParent.

new AnchorScroller({
  "class": "scroll", // will make it only react on elements with a "scroll" class.
  checkParent: true // will make it check the parent element, if the clicked element didn't match the criteria.
});

The more in-depth usage guide also has documentation on all options and methods.

2.0.1

7 years ago

2.0.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago