npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

active-scroll

v1.0.2

Published

jQuery Plugin for smooth scrolling with anchor highlighting

Downloads

208

Readme

ActiveScroll.js Build Status

This jQuery plugin allows for Smooth Scrolling with Anchor Highlighting.

ActiveScroll.js determines which targeted element is closer to the page scroll position and highlights that anchor. It provides a smooth scrolling feature with an onclick event attached to a customised data attribute.

Highlighting will only apply to anchors in the initiated container. However all links with the data attribute will have the scrollTo feature.

$('nav').activescroll({
    scroll: "scroll",
    active: "active",
    offset: 20,
    animate: 1000
});

Installation

NPM

Make sure you have node.js installed. It comes bundled with npm

npm install active-scroll --save

Bower

Make sure you have bower installed.

bower install active-scroll --save

Usage

Make sure you have a data attribute that references the id of the element that the page will be scrolled to.

<nav>
    <ul>
        <li data-scroll="intro">Introduction</li>
        <li data-scroll="basic">Basic</li>
    </ul>
</nav>
...
<h2 id="intro">Introduction</h2>
...
<div id="basic">
    <p>Hello World</p>
</div>

Inititate the plugin on the element that contains all the data bindings.

$('nav').activescroll();

Settings

data (default: scroll)

The data setting looks for the data attribute to define the anchor tags. For compatability with other plugins you can change the bind in the options.

<nav>
    <ul>
        <li data-link="intro">Introduction</li>
        <li data-link="basic">Basic</li>
    </ul>
</nav>
$('nav').activescroll({
    data: "link"
});

active (default: active)

The active setting determines the class name to attach to the anchor if it highlighted.

<nav>
    <ul>
        <li data-scroll="intro">Introduction</li>
        <li data-scroll="basic">Basic</li>
    </ul>
</nav>
$('nav').activescroll({
    active: "highlight"
});

So if Introduction was determined to be the active Anchor:

<nav>
    <ul>
        <li class="highlight" data-scroll="intro">Introduction</li>
        <li data-scroll="basic">Basic</li>
    </ul>
</nav>

offset (default: 20)

The offset setting determines the offset of the scrollTo position.

$('nav').activescroll({
    offset: 10
});

animate (default: 1000)

The animate setting determines the ms the scrollTo should take.

$('nav').activescroll({
    animate: 2000
});