Create lazy image, embed, video and element with animation just with attributes.

Overview

📖 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

supported browser

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;
}
You might also like...
Lazy load background images for Vue 2

Lazy Background Images for Vue vue-lazy-background-images A simple Vue component for lazy loading background components. This component is only for ba

A plugin of lazy-load images for Vue2.x
A plugin of lazy-load images for Vue2.x

vue-lazyload-images A plugin of lazy-load images for Vue2.x Support images lazyload in window or build-in element. Demo Installation npm $ npm install

Component-based lazy (CLazy) load images in Vue.js 2

Vue Clazy Load Claziest lazy loader out there! Component-based image lazy loader for Vue.js 2 Swaps between your image and another component when load

🐌 A small size Vue.js directive for lazy loading images using IntersectionObserver API

🐌 vue-tiny-lazyload-img A small size Vue.js directive for lazy loading images using IntersectionObserver API Demo Page https://mazipan.github.io/vue-

Flexible modal component for Vue with ability of asynchronous lazy loading

vue-async-modal Flexible modal component for Vue with ability of asynchronous lazy loading Usage Firstly, you should add Modal component in your templ

simple calculation lib with lazy feature 🎲➕➖➗✖️
simple calculation lib with lazy feature 🎲➕➖➗✖️

vue-lazy-calc this is a simple calculation plugin in lazy way. (inspired by lodash) features vue friendly strong typed lazy evaluation chaining method

A Lazy load plugin for Vue 3.x

vue3-lazy Status: Alpha. Lazy load plugin for Vue 3.x inspired by vue-lazyload. This plugin support very simple options, and easy to use. Install $ np

A Vue lazy loading directive.

A Vue lazy loading directive.

A Vue.js component to lazy load images using the Intersection Observer.

vue-li-image A Vue.js component to lazy load an image automatically when it enters the viewport using the Intersection Observer API.

Releases(1.2.1)
Owner
Learning javascript, css, html, node.js, vuejs, tailwindcss, react, typescript ...
null
A simple lazy-load list component based Vue 2.x: https://dwqs.github.io/v2-lazy-list/

v2-lazy-list A simple lazy-load list component based Vue 2.x, which will be on-demand rendering the list based container element's viewport. v1.x is n

Pomy 31 Nov 18, 2020
Vue.js lazy load image directive with akamai image converter

vue-lazyload-akamai Vue.js lazy load image directive with akamai image converter ??

Blibli.com 2 Aug 13, 2018
:camera: Mini Image Lazy Loader for P(R)eact and Vue

Pimg is a Progessive Image Component For React, Preact and Vue.js. It helps in lazy loading of images in a nice and cool way. It's 2KB (gzipped). It h

Ademola. 98 Apr 24, 2021
Vue.js Image Kit Component with Lazy Load built in and Responsive Images

Vue Image Kit Vue.js Image Kit Component with Lazy Load built in and Responsive Images The inspiration comes from this and a talk from @derevandal in

Igor Guastalla 9 Mar 31, 2022
simplistic vue.js directive for image lazy loading

Vue Progressive Image Lazy load images while showing a preview. Super tiny, less than half a kilobyte minified and gzipped. usage v-lazy-img adds the

Norman 25 Aug 11, 2021
A small lazy image loader for Vue

lazy-vue lazy-vue is the easiest way to get a lazy image loader working within your vue projects. It is meant to be as simplest as possible, so you do

Gustavo Ocanto 63 Jul 19, 2022
A super simple image lazy loader for Vue.

cube-vue-image-lazy A super simple image lazy loader for Vue. Install yarn add cube-vue-image-lazy Warning: You'll need to install the w3c Intersectio

Cube 4 Jun 19, 2020
A lightweight web package that loads items in lazy way to achieve high performance and better UX in large lists

Lazy Load List Lazy Load List is a lightweight web package that loads items in lazy way to achieve high performance and better UX in large lists. Rend

OMER ANWAR 18 Sep 26, 2022
A vue component for sleek and optimal lazy loading

sloth-loader ?? Image Lazy loader Vue Component with intersection observer Example here Installation yarn add sloth-loader npm i sloth-loader import c

Kenny Krosky 0 Oct 21, 2021
vue lazy container,By detect the visibility of elements in the page, decide whether to load resources and render.

vue lazy container,By detect the visibility of elements in the page, decide whether to load resources and render.

null 5 Sep 25, 2022