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

single-page-nav

v1.0.0

Published

Apply the 'singlePageNav' function to a container element. Clicking on any links within the container will cause an animated scroll down to the element whose ID is identified by that link's "hash" (if it exists). The currently highlighted link in the nav

Downloads

1,721

Readme

Single Page Nav

Apply the 'singlePageNav' function to a container element. Clicking on any links within the container will cause an animated scroll down to the element whose ID is identified by that link's "hash" (if it exists). The currently highlighted link in the nav bar will also cycle as the user scrolls down the page (useful with a fixed-position nav bar. Intended for use on single page websites, such as a portfolio.

Bug reports and pull requests more than welcome. This was my first plugin release.

Live demo: http://chriswojcik.net/demos/single-page-nav/

Features

  • The coordinates of each target element are determined dynamically, resizing the browser or appending content to a section will not break the plugin.
  • Configurable options.

Sample Use

$('#navigation-bar').singlePageNav();

Options

  • 'offset' - An offset in pixels above the target element when scrolling (useful for accounting for the height of a "sticky navigation bar", see the demo)
  • 'threshold' - The distance above each section in pixels when the "current" link in the nav bar will change.
  • 'speed' - The animated scroll speed in milliseconds.
  • 'easing' - The easing function to use with the animation (Default is 'swing').
  • 'currentClass' - The class to apply to the link in the nav bar corresponding to the active section on the page.
  • 'updateHash' - In browsers that support the history object, update the url's hash when clicking on the links (Default is false)
  • 'filter' - By default, the plugin will be applied to all links within the container, use this to filter out certain links using jquery's built in filter method (e.g. ':not(.external)')
  • 'beforeStart' - This function will fire when a user clicks on a link but before the scrolling animation starts
  • 'onComplete' - This function will fire when the scrolling animation completes

Limitations

  • The order of the links in the navigation bar MUST match the order of the sections as laid out on the page or unexpected behavior will occur.

TODO (future updates)

  • Add support for horizontal scrolling sites.
  • Determine best way to handle multiple instances on the same page.
  • Add support for BOWER.

References

The functionality of this plugin is admittedly similar to some others. But it was my first plugin, so be kind. Here are a few links to such plugins if you find them more helpful.

  • [onePageNav plugin] (https://github.com/davist11/jQuery-One-Page-Nav)
  • [scrollTo plugin] (https://github.com/flesler/jquery.scrollTo)
  • [jQuery Waypoints] (https://github.com/imakewebthings/jquery-waypoints)