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

vt-lazyload

v1.1.7

Published

Really small lazyload plugin for vue (<7kB).

Downloads

6

Readme

Lazyload plugin

build npm version license

Really small lazyload plugin for vue (<7kB).

If you have a idea for a new feature or option, add it to the Issues on my github repo. :)

How to install:

  1. Install the package:

    #install the npm package
    
    npm i vt-lazyload
  2. Import/use plgun:

    import Vue from "vue";
    import lazyLoad from "vt-lazyload";
    
    Vue.use(lazyLoad);

How to use:

Add the v-lazyLoad directive with the src of the image as attribute value.

Do not add the src Attribute or else that lazyload wont work.

With url:

<img v-lazyLoad="'https://via.placeholder.com/350x150'" />

With prob/variable:

<img v-lazyLoad="image.src" />

lazyloading:

When using this plugin on a browser that supports native lazyloading, the plugin automaticly adds the necessary attributes and values to your element with the v-lazyload directive.

If you add options to the Vue.use() the native lazyloading won't be added to your element. Therefore the custom lazyload will be added to the element

Options:

How to add a option:

Add a object to the Vue.use(lazyload)

Vue.use(lazyLoad, { margin: "0px 0px 100px 0px" });

Options:

| Option | Type | Default value | Description | | ---------- | ------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | margin | string | '0px 0px 100px 0px' | Sets the distance between the viewport and the image before it gets loaded | | fadeIn | boolean | false | If you want the images to fade in when scrolling by, set the value to a css transition e.g. 'opacity 0.3s ease' | | directive | string | 'lazyLoad' | Use this option to change the directive name, if you change it to 'lazy' the directive name becomes v-lazy | | cssAnimate | boolean | false | Use Animate.css on your lazyload image | | errorImg | string | false | Sets a placeholder image when image couldn't load, to use this function passtrough the url of the placeholder image | | errorClass | string | imageFailed | This class name will be added to the image when it failed to load. Add errorClass with the class name you like to the options to change the default classname. |

Using multiple options:

Vue.Use(lazyLoad, {
  margin: "0px 0px 50px 0px",
  errorImg:
    "https://cdn.dribbble.com/users/1274627/screenshots/3390285/404-error-sad-boat-800x600.jpg"
});

How to use the cssAnimate option:

  1. Find the animation you want on animate.css

  2. Add the animation in the animation array and add some options if you want. (The order of the array doesnt matter)

<img v-lazyLoad="{ url: backgroundImage, animation: ['zoomInLeft', 'slower'] }" />