angular-lazy-loader
v2.1.0
Published
angularjs directive for lazy loading images, background images, and embedded videos
Downloads
122
Readme
#angular-lazy-loader
AngularJS lazy loading directive for lazy loading images and videos(via iframe).
Description
A 1 kB minimalistic and lightweight AngularJS directive to lazy load images, background images, and iframes.
Installation
npm install angular-lazy-loader
Demo
http://tarun-dugar.github.io/angular-lazy-loader/
Usage
Include angular-lazy-loader.min.js after the angularjs library.
Or, you can use
require
:var lazyLoader = require('angular-lazy-loader');
Add the 'angular-lazy-loader' module to your app as follows:
angular.module('yourApp', ['angular-lazy-loader'])
Add the attribute (directive) 'angular-lazy-load' to the HTML element within which you want to lazy load images and iframes:
<div angular-lazy-load> </div>
Optionally, set the threshold attribute that accepts a pixel value to load the asset when it is 'threshold' pixels away (vertically) from the viewport.
<div angular-lazy-load threshold="200"> </div>
Replace 'src' attribute of 'img', 'iframe', and 'div' tags with 'data-src':
<img data-src="<your_url>" />