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

lazy-attr

v1.2.3

Published

Create lazy loading request or element like image, iframe, video... Make custom animation on lazy and not lazy element on all browser. You can also use our animations included in the lib. All of that just with html attributes.

Downloads

56

Readme

📖 Lazy-attr v1.2.3

npm Download

Create lazy loading request or element like image, iframe, video... Make custom animation on lazy and not lazy element on all browser. You can also use our animations included in the lib (Demo). All of that just with html attributes.

All browser supported

Example


<img lazy-src="https://picsum.photos/300/300?random=1" lazy-srcset="https://picsum.photos/300/300?random=2 900w" lazy-animation="corner-top-left" lazy-reset>

🎉 Update


📚 Documentation & Demo


💻 Import


Node

import lazyattr from "lazy-attr";
import "lazy-attr/dist/lazy-attr-animation.css";

//Vue.use(lazyattr)

CDN

<script src="https://unpkg.com/[email protected]/dist/lazy-attr.js" type="text/javascript"></script>
<link href="https://unpkg.com/[email protected]/dist/lazy-attr-animation.css" rel="stylesheet"/>

From download

<script src="./dist/lazy-attr.js" type="text/javascript"></script>
<link href="./dist/lazy-attr-animation.css" rel="stylesheet"/>

Events


  • lazy-loaded When the element is matched
  • lazy-quit When the element is not matched

Lazy request


  • You can add lazy-reset if you want to dispatch the event not just once time
<div id="cars" lazy-observe></div>
document.querySelector('#cars').addEventListener('lazy-loaded', function(event){
    const target = event.target;
    target.textContent = "Hey I'm lazy";
});

Class


  • You can set a class lazyattr wich be transform in lazyloaded after the element is loaded (work on the pointer and parent)
  • You can make a beatiful skeleton loader with lazy-skeleton, lazy-skeleton-corner and lazy-skeleton-top class

Skeletons


  • To set a skeleton loader on an image pls set it on his parent. After you need to put lazy-animation-pointer="#parent" on the image to remove it after load.
  • Set a skeleton loader on a div with lazy-background will automatically remove it after load.

Attributes


Image, iframe and video

| Parameters | Usage | |:-----------------------:|:--------------------------------------------------------------------------------------------:| | lazy-observe | Just observe the element to do lazy request for example | | lazy-reset | Reset the animation on scroll | | lazy-srcset | Same as srcset attribute | | lazy-src | Image soucre | iframe source | video source | | lazy-background | Image source to make a lazy background image | | lazy-size-width | Minimum width size | | lazy-size-height | Minimum height size | | lazy-animation | Animation to lauch after full load of element | | lazy-animation-time | Animation duration (time in ms) | | lazy-animation-delay | Animation delay (time in ms) | | lazy-animation-pointer | Wich element will be animated after the lazy element is load (expl: "#id", ".class", "tag") | | lazy-animation-function | Animation timing function like css | | lazy-animation-count | Animation repeatition like css (expl: infinite) |

Video

| Parameters | Usage | |:----------:|:-----------------------------------------------:| | lazy-video | Put a poster while user dont click on the video |

Iframe / Embed

| Parameters | Usage | |:-----------:|:-----------------------------------------------:| | lazy-embed | Iframe link | | lazy-poster | Put a poster while user dont click on the video |

Methods


window.lazy()

| Parameters | Usage | |:------------------------:|:----------------------------------------:| | version | Get actual version of lazy-attr | | parameters | Get all possible attributes of lazy-attr | | animations | Get all animations |

Animations


How

Example

<img lazy-src="..." lazy-srcset="..." lazy-animation="corner-top-left">

Animations list

zoomin
zoomout
opacity
slide-left
slide-right
slide-bottom 
slide-top
corner-top-left
corner-top-right
corner-bottom-left
corner-bottom-right
shake
rotate
blur
flip
flip-up

Create your animation

.my-name{
    opacity: 0;
    animation: animation-name 1s forwards;
}

@keyframes animation-name{
    100%{
        opacity: 1;
    }
}

Modify velocity for prebuild animations

  • Work on scale and slide animations
  • By default it's:
:root{
    --slide-start: 33%;
    --slide-velocity: 7px;

    --scale-velocity: 0.035;
    --scale-start: 0.4;
}