RevillWeb / angular-preload-image

A simple AngularJS module to make it easy to pre-load images.
MIT License
70 stars 29 forks source link

angular-preload-image

A simple AngularJS module to make it easy to pre-load images to prevent the horrible waterfall effect: Demo.

Installation

Install with bower

bower install angular-preload-image

Include script files

<script src="https://github.com/RevillWeb/angular-preload-image/raw/master/bower_components/angular/angular.min.js"></script>
<script src="https://github.com/RevillWeb/angular-preload-image/raw/master/bower_components/angular-preload-image/angular-preload-image.min.js"></script>

Add module dependency

angular.module('app', ['angular-preload-image']);

Usage

Pre-load background images

<div preload-bg-image="[URL]" default-image="[URL]" fallback-image="[URL]"></div>

Pre-load standard images

<img preload-image ng-src="https://github.com/RevillWeb/angular-preload-image/raw/master/[URL]" default-image="[URL]" fallback-image="[URL]" />

Licence

MIT

Demo

Check out the demo for an example of pre-loading background images and pre-loading standard images with AngularJS.

TO DO

Credit

Inspiration taken from Ben Nadel's post about pre-loading images.