Load your images in style using Angular: add an overlay before and during the image load, with the exact same position and dimensions of the image.
| Without Angular Pretty Load | With Angular Pretty Load |
|---|---|
![]() |
![]() |
We will leave the Issues open as a discussion forum only. We do not guarantee a response from us in the Issues. We are no longer accepting pull requests.
Just use Bower.
bower install angular-pretty-load --save
Then, inject it into your application:
angular.module('MyApp', ['platanus.prettyLoad']);
In order to use the most basic mode, you should specify both the width and height of the image in your CSS
<img pretty-load ng-src="http://your.image.jpg">If one or both dimensions are not specified in your CSS, but the API you're consuming or the server behind can provide the original size use this:
<img ng-src="{{image.src}}"
pretty-load
pretty-load-width="{{image.width}}"
pretty-load-height="{{image.height}}">The directive will not override properties given to the image (width: 100%), but it will complete both width and height based on the original image ratio.
You can set a common overlay color for all images:
.pretty-load-overlay {
background-color: #333;
}or customize it for every image:
<img ng-src="{{image.src}}"
pretty-load
pretty-load-width="{{image.width}}"
pretty-load-height="{{image.height}}"
pretty-load-color="{{image.color}}">You have total control on how to handle the CSS transition from the overlay to the final image.
This CSS will give you the same results as the demo:
.pretty-load-overlay {
opacity: 0;
}
.pretty-load-loading .pretty-load-overlay {
opacity: 1;
transition: opacity 0.5s ease;
}
.pretty-load-completed .pretty-load-overlay {
opacity: 0;
transition: opacity 1.7s ease;
}The directive wraps the image inside a div element. This container will have the following classes applied according to the state of the image inside:
.pretty-load-init: added when the directive is initialized.pretty-load-loading: added when the directive is initialized and removed when the image finishes loading.pretty-load-completed: added when the image finishes loading
These are used in our example CSS and you can use them to control additional (for example, a spinner icon) or create more complex transitions between these states.
- Note:
angular-pretty-loaddoes not handle lazy loading. You would have to use an additional library for that.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
Thank you contributors!
angular-pretty-load is maintained by platanus.
© 2015 Platanus, SpA. It is free software and may be redistributed under the terms specified in the LICENSE file.

