GithubHelp home page GithubHelp logo

lazyload.js's Introduction

lazyload.js

native js write image lazyload

查看demo

git clone https://github.com/523451928/lazyload.js.git
cd lazyload.js
npm install
npm run dev

lazyload 使用方法

new Lazyload(document.querySelectorAll('img'), {
    error: 'http://upload-images.jianshu.io/error.jpg',
    loading: 'https://timgsa.baidu.com/timg?loading.jpg',
    elm:elm,            //需要懒加载的图片数组
    src:"imgsrc",       //默认给图片地址的属性
    threshold:100,	    //提前加载距离
    opa:0.3,		        //图片初始透明度
    isBg:false,         //是否为背景图
    delay: 500,         //节流时间
    hasLoadingImg:false  //是否有loading图片 为true 当图片全部加载完成之后不会移除事件绑定
})
Option Description
error String(default '') 加载错误的error图片
loading String(default '') 未加载之前的loading图片
src String(default 'imgsrc') 默认给图片地址的属性
threshold Number(default 100) 提前加载距离
opa Number(default 0.3) 未加载之前的图片透明度
isBg Bollean (default false) 是否为背景图
delay Number(default 500) 节流时间
hasLoadingImg Bollean(default false) 是否有loading图片 为true 当图片全部加载完成之后不会移除事件绑定

lazyload.js's People

Contributors

523451928 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.