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

lazload

v1.0.4

Published

An image/video lazy loading library, which has a few premade cool images reveal effect after it loads the image

Downloads

32

Readme

LazLoad

NPM Version NPM Downloads

What is this?

This is a library which can lazy load:

  • Images
  • Videos

There are multiple premade image/video reveal animations after the image/video is loaded. More will be added soon. (Please show your support!)

You can set your own animations if you want as well. Just set the identifier: '.any-class-you-like' and use the onContentLoaded: function(element, url){} callback to perform any action/animation on that element

Animation Examples

| | | | :----------: | :----------------: | | Fade in | White Overlay |

Benefits

  • Fast CSS3 animation which uses the GPU
  • Extremely lightweight: Only 7.2kB (1.9kB gzipped)
  • No dependency: It's all Pure javascript

CDN

<script src="https://unpkg.com/[email protected]/src/lazload.js">

And then use it like this:

<img class="laz" data-src='...'>
<video class="laz" data-src='...'></video>
LazLoad().init();

NPM Installation

npm i lazload

And then use it like this:

<img class="laz" data-src='...'>
<video class="laz" data-src='...'></video>
import LazLoad from 'lazload';

LazLoad().init();

Callback Examples

new LazLoad({
  onContentLoaded: (element, url) => {
    console.log("Im loaded: " + url);
    element.style.transform = "rotate(30deg)"; // Any animation you want to perform
  },
}).init();
new LazLoad({
  onLoadError: (element) => {
    console.log("Error loading: " + element.src);
  },
}).init();

Options

// These are the Defaults
new LazLoad({
  identifier: ".laz",
  revealAnim: LazLoad.anims.SLIDE_UP_WHITE,
  triggerRadius: 300,
  onContentLoaded: function(element, url){}
  onLoadError: function(element){}
}).init();
  • identifier: [string] Identify which elements should be parallaxed
  • triggerRadius: [int] [value > 0] How close to the scroll from top should the lazy loading get triggered. The higher the number, the closer it gets to being lazy loaded with scroll.
  • revealAnim: [LazLoad.anims.OPTION_NAME] Possible values:
    • LazLoad.anims.NONE
    • LazLoad.anims.SLIDE_UP_WHITE
    • LazLoad.anims.SLIDE_UP_BLACK
    • LazLoad.anims.SLIDE_UP_CUSTOM_COLOR
  • overlayCustomColor: [color] To use this, revealAnim must be LazLoad.anims.SLIDE_UP_CUSTOM_COLOR
  • onContentLoaded: [function] This callback event is triggered once the lazy-loading content has finished loading
  • onLoadError: [function] This callback event is triggered if content failed to load

Using custom colors for sliding overlay

// MUST! revealAnim: LazLoad.anims.SLIDE_UP_CUSTOM_COLOR
new LazLoad({
  revealAnim: LazLoad.anims.SLIDE_UP_CUSTOM_COLOR,
  overlayCustomColor: "rgb(255, 123, 100)",
}).init();

Achieve the shown examples gifs effects

/* Use this for the images you want to parallax */
.parallax-element{
  object-fit: cover; // Fixes image ratio
}