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

jquery.r5-scrollspy

v1.0.0

Published

A jQuery lightweight plugin that keeps track of the current on-screen elements.

Downloads

11

Readme

jQuery r5 Scroll Spy

A jQuery plugin, that keeps track of what elements currently are on the screen.

Usage:

  1. Include jquery.r5-scrollspy.js after jQuery at the bottom of your document (before the </body>)

    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.slim.min.js"></script>
    <script src="/path/to/jquery.r5-scrollspy.js"></script>

    Requirement: jQuery version >=1.7.0 testet up to version 3.2.1-slim

  2. Add a collection to scrollspy

    (function($){
        $('.screen').scrollspy(options);
    })(jQuery);

    Where .screen is the class of all elements you want to track and options is a non mandatory object that overwrites the default settings.

    You can either embed this in a <script></script> tag directly into your HTML, or add this to one of your javascript files.

Options

r5 Scroll Spy comes with a few default values :

scrollElement

Default: window - can be window, document or any String css selector.

This is the element that gets scrolled.

activeClass

Default: onScreen - can be any String.

This class will be added to the element that is currently considered on screen.

throttle

Default: 250 - Integer

Throttle the scroll trigger to only trigger every interval. 1000 = 1 second.

Lower numbers increase the viewers CPU load but might make animations more smooth.

distanceBottomUnit

Default: fraction - can be either fraction, pixel (short: px) or percent (short: %)

Depending on the choosen distanceBottomUnit the distanceBottom will be calculated.

  • fraction means a partial/fraction of the screen.

    e.g. the element is in the current viewport for 1/3 from the bottom

  • pixel|px means pixels from the bottom.

    e.g. the element is in the current viewport for 250 pixels from the bottom

  • percent|% means percent from the bottom.

    e.g. the element is in the current viewport for 10% from the bottom

distanceBottom:

Default: 3 - Integer

Describes the unit-less value of distanceBottomUnit

Positive values mean, the element is at least that much scrolled in from the bottom to be considered on screen.

Negative values mean, the element is at least maximum that much away (out of screen) the bottom to be considered on screen.

0 means, as soon as the element passes the bottom of the screen it is considered on screen

addSideClasses

Default: false - Boolean

If true, elements that are scrolled in and out of the screen get a vlass with the in and out classes attached.

Classes are: in-top, in-bottom, out-top, out-bottom

inCallback

Default: function ($element, side) {return true;} - Function

In this callback you can add your own magic.

First parameter $element references the jQuery element that is currently scrolled in.

Second parameterside is the side where the element scrolled in from (either bottom or top).

outCallback

Default: function ($element, side) {return true;} - Function

In this callback you can add your own magic.

First parameter $element references the jQuery element that was marked as on screen last.

Second parameterside is the side where the element scrolled out to (either bottom or top).

##Demo A demo can be seen in the examples/ folder.