GithubHelp home page GithubHelp logo

trendingtechnology / vue-lazyload-img Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wormsan/vue-lazyload-img

0.0 2.0 0.0 4.5 MB

a plugin of vue for image lazyload, especially optimized for mobile browser(vue图片懒加载插件,特别为移动端优化)

Home Page: http://docs.gomeminus.com/vue-lazyload-img/test/bundle.html

License: MIT License

JavaScript 97.13% HTML 2.87%

vue-lazyload-img's Introduction

English doc

Finally Available on vue2, if you use v1, use npm install vue-lazyload-img@1

vue-lazyload-img

intro

   a plugin of vue for image lazyload, especially optimized for mobile browser

demo

Use mobile mode if possible

var with script tag

bundle with webpack

API

init

Vue.use(Lazyload[,options])

options

global options

fade: all images will use fadein fx

  • true: all images will fadein if lazyload Complete
  • false (default): no fadein fx of all

speed: threshold of loading lazyload iamge

  • 0 : load lazy-image when the image is visible at the 1st time
  • 0 (defult 20): average changes of document y-pos and any scroller's x-pos from last 10 frames, awesome in mobile browsers

time: duration of fade in or fade out

  • 300 (default, unit: ms)
Vue.use(Lazyload,{
    fade: true,
    speed: 20,
    time: 300
})

directive

v-lazyload

  • v-lazyload="src"

How to import?

In CommonJs

1st

npm install vue-lazyload-img

2nd

es6

import Lazyload from "vue-lazyload-img"
Vue.use(Lazyload)

es5

var Lazyload = require("vue-lazyload-img")
Vue.use(Lazyload)

in this way, you'll need babel or something like it

In browser

because this plugins supports umd, so you can use it as a <script> or with JS module loader like require.js.

the released bundle is in:

dist/vue.lazyimg.min.js dist/vue.lazyimg.js

roadmap

  • to support the API in v1 but not in v2 now
  • make a UI component system with future libs

Chinese doc

vue-lazyload-img

目前新版本升级到v2,使用v1的同志们,请使用npm install vue-lazyload-img@1安装

介绍

vue图片懒加载插件,特别为移动端优化

适配vue2的更新

作为vue-ui-kit体系的可搭配套件使用, on roadmap

示例

var with script tag

bundle with webpack

如何引入?

在CommonJs中

首先

npm install vue-lazyload-img

然后

es6

import Lazyload from "vue-lazyload-img"
Vue.use(Lazyload)

es5

var Lazyload = require("vue-lazyload-img")
Vue.use(Lazyload)

由于源码使用了部分es6特性需要使用类似babel的工具进行编译

在浏览器中

由于使用了umd规范,所以可以用<script>标签引入,或使用其他的JS模块加载器,比如require.js

引用dist/vue.lazyimg.min.jsdist/vue.lazyimg.js即可

v1迁移到v2

兼容

  • 目前v2不支持可扩展的directive
  • 目前不支持横向检测(nohori暂时失效)

上述问题后续版本会解决

引用

  • require("vue-lazyload-img") 改为 var Lazyload = require("vue-lazyload-img")
  • Vue.use(Vue.lazyimg) 改为 Vue.use(Lazyload)

路线图

  • 覆盖v1中的功能
  • 后续会继续放出如scroller、swiper等工具,形成体系套件

vue-lazyload-img's People

Contributors

blue0728 avatar whwnow avatar wormsan avatar

Watchers

 avatar  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.