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

evolvethemes-inviewr

v1.0.3

Published

JavaScript library to detect when elements come into view.

Downloads

2

Readme

Inviewr

Inviewr is a JavaScript library that allows you to detect when elements come into view. It has no dependencies, it's very lightweight (less than 1kB gzipped), and it's based on the new IntersectionObserver, so it's easy on browser resources as well.

Should you use the library on an older browser, Inviewr falls back to a compatibility mode that uses window events instead.

Installation

Here's what you need to do to include the library in your project:

NPM

If you're using NPM and a tool such as Webpack, simply download the package with the following command:

npm install evolvethemes-inviewr --save

Standard way

Download the minified script from the dist folder in this repository (the master branch holds the latest release, while the dev branch is for development purposes).

Usage

In order for an element to be kept track of, it needs to be registered with the library.

Once included, the library activates itself on the DOMContentLoaded event, which means that before the event is actually fired we have time to declare which group of elements we are going to track.

To register elements, we can use their CSS selector:

window.inviewr.register( "img", { toggle: true } )

The above code will be interpreted by the library as a "_let's keep track of all img elements, and let's fire events whenever they come in or out of view".

When an element becomes viewable, two things happen:

  • the element is given an evolvethemes-inviewr class,
  • the element emits an evolvethemes-inview event.

When an element isn't viewable anymore, instead:

  • the evolvethemes-inviewr class is removed from the element,
  • the element emits an evolvethemes-not-inview event.

When registering an object for tracking, the second parameter is an options object. As of today, these are the option settings available:

  • toggle: false - When set to true, the classes are added/removed depending on the element's in-view status; if left to false, the class is not removed when the element goes out of view.

What's Evolve Themes

At Evolve we're specialized in the creation of top notch products based on WordPress, and under the Evolve Themes brand we regularly publish and sell themes and plugins.