1.2.3 • Published 2 years ago

lazy-attr v1.2.3

Weekly downloads
44
License
MIT
Repository
github
Last release
2 years ago

📖 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/lazy-attr@1.2.3/dist/lazy-attr.js" type="text/javascript"></script>
<link href="https://unpkg.com/lazy-attr@1.2.3/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

ParametersUsage
lazy-observeJust observe the element to do lazy request for example
lazy-resetReset the animation on scroll
lazy-srcsetSame as srcset attribute
lazy-srcImage soucre | iframe source | video source
lazy-backgroundImage source to make a lazy background image
lazy-size-widthMinimum width size
lazy-size-heightMinimum height size
lazy-animationAnimation to lauch after full load of element
lazy-animation-timeAnimation duration (time in ms)
lazy-animation-delayAnimation delay (time in ms)
lazy-animation-pointerWich element will be animated after the lazy element is load (expl: "#id", ".class", "tag")
lazy-animation-functionAnimation timing function like css
lazy-animation-countAnimation repeatition like css (expl: infinite)

Video

ParametersUsage
lazy-videoPut a poster while user dont click on the video

Iframe / Embed

ParametersUsage
lazy-embedIframe link
lazy-posterPut a poster while user dont click on the video

Methods


window.lazy()

ParametersUsage
versionGet actual version of lazy-attr
parametersGet all possible attributes of lazy-attr
animationsGet 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;
}
1.2.3

2 years ago

1.2.2

2 years ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago