Socket
Socket
Sign inDemoInstall

lazy-attr

Package Overview
Dependencies
0
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lazy-attr

Lazy and animation lib. Create lazy 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.


Version published
Maintainers
1
Created

Changelog

Source

1.2.0

  • No more .min.js or .min.css
  • No more prefix -animation after the animation name
  • Improvement for animations and lazy-attr
  • Node module added

Readme

Source

📖 Lazy-attr v1.2.0

npm Download

Create lazy 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.

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


  • No more .min.js or .min.css
  • No more prefix -animation after the animation name
  • Improvement for animations and lazy-attr
  • Node module added

📚 Documentation & Demo


💻 Import


  • You just need to import the css file and the js file
  • In browser put it in the <head>
  • In vue.js you can put it in the public.html file

CDN

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

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-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-callbackFunction name lauched after full load of element
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 animation prefix

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;
}

Keywords

FAQs

Last updated on 16 Nov 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc