npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-images-lazy-load

v1.0.11

Published

Vue plug-in for images lazy loading

Downloads

48

Readme

为了提升页面响应速度,优化用户体验,可以适当的减轻页面首次加载的压力,可以使用图片懒加载。
In order to improve the page response speed and optimize the user experience, it can reduce the pressure of the first page loading appropriately. You can use the image lazy loading. https://img.shields.io/npm/v/vue-images-lazy-load.svg?label=vue-images-lazy-load 总下载量

安装/Install

npm install vue-images-lazy-load --save

使用/Use

全局注册/Global registration (main.js)

import VueImgLazyLoad from 'vue-images-lazy-load';
// default
Vue.use(VueImgLazyLoader);
// options
Vue.use(VueImgLazyLoader, {
    observerOptions: {
	rootMargin: '0px 0px -400px 0px',
	threshold: 0.5
    },
    delayTime: 1000
});
options
  • oberserOptions: 观察者参数配置。
    rootMargin:可以区域范围,比如:"0px 0px -100px 0px",则为元素超出视窗底部100px被视为可见;默认'0px'
    threshold(0-1): 元素达到视窗设置的rootMargin,还要加上自身的百分比被视为可见;默认0
  • delayTime :给图片添加延时加载的时间,default: (Math.random() * 500)
  • oberserOptions: observer parameter configuration.
    rootMargin:areas such as "0px 0px-100px 0px" are considered visible if the element exceeds 100px at the bottom of the window; default is'0px'.
    threshold(0-1):elements that reach the rootMargin of the window settings, plus their own percentages, are considered visible; default 0
  • delayTime : add a delay loading time to the picture,default: (500 + Math.random() * 500)

tips

最开始的名字有冲突,所以使用了vue-images-lazy-load
The initial name was conflicting, so vue-images-lazy-load was used.

局部注册/Partial registration (*.vue)

import { directive } from 'vue-images-lazy-load';
directives: {
    'img-lazy-load': directive
}

*.vue

使用默认配置/use default config
<img :src="baseUrl" v-img-lazy-load />

参数配置/Parameter configuration

  • url:替换插件默认的展位图,格式请用base64格式,或者提起解析好的(require,import),或者cdn地址
    url: Replace the default booth map of the plug-in, in base64 format, or mention parsed(require,import) or CDN address.
<img :src="baseUrl" v-img-lazy-load="{url: ''}" />