vue-li-image
A Vue.js component to lazy load an image automatically when it enters the viewport using the Intersection Observer API.
This is an opinionated upgrade of the original Vue Lazy Image loading library v-lazy-image including certain fixes already submitted as pull requests on the original library, which were never merged. Kudos to Alex Jover for the original idea!
Usage
npm install vue-li-image
Warning: You'll need to install the w3c Intersection Observer polyfill in case you're targeting a browser which doesn't support it.
You can register the component globally so it's available in all your apps:
import Vue from "vue";
import { VueLiPlugin } from "vue-li-image";
Vue.use(VueLiPlugin);
Or use it locally in any of your components:
import VueLi from "vue-li-image";
export default {
components: {
VueLi
}
};
You must pass an src
property with the link of the image:
<template> <vue-li src="http://lorempixel.com/400/200/" /> template>