
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
angular-lazy-img
Advanced tools
Lightweight lazy load images plugin. Only 1kb after gziping. Pure JavaScript, only Angular as dependency.
bower install --save angular-lazy-img
Include angular-lazy-img
in your HTML.
<script src="<your-bower-components>/angular-lazy-img/release/angular-lazy-img.js"></script>
Inject the angular-lazy-img
module in your application.
angular.module('your.module', [
'angularLazyImg'
]);
Just add lazy-img attribute with source to file that you want to lazy load
<img lazy-img='photo.jpeg' />
If you want show spinner put it in src attribute
<img src='spinner.gif' lazy-img='photo.jpeg' />
You want to lazy load background image? No problem, add directive to anything you like and it will handle the rest.
<div lazy-img='photo.jpeg'></div>
If you need to run the image check manually (for example when clicking on tabs that filter your image result), you can trigger it that way:
$rootScope.$emit('lazyImg:refresh');
On success and error lazyImg will trigger events on $rootScope - lazyImg:success and lazyImg:error, passing as first param image
Inside your config require 'lazyImgConfigProvider' and set custom options.
angular.module('your.module', [
'angularLazyImg'
]).config(['lazyImgConfigProvider', function(lazyImgConfigProvider){
var scrollable = document.querySelector('#scrollable');
lazyImgConfigProvider.setOptions({
offset: 100, // how early you want to load image (default = 100)
errorClass: 'error', // in case of loading image failure what class should be added (default = null)
successClass: 'success', // in case of loading image success what class should be added (default = null)
onError: function(image){}, // function fired on loading error
onSuccess: function(image){}, // function fired on loading success
container: angular.element(scrollable) // if scrollable container is not $window then provide it here
});
}])
Just add lazyImgContainer
attribute to your scrollable container to be considered when you scroll him.
Copyright 2014, Paweł Wszoła (wszola.p@gmail.com)
FAQs
Plugin for lazy loading images in Angular
The npm package angular-lazy-img receives a total of 544 weekly downloads. As such, angular-lazy-img popularity was classified as not popular.
We found that angular-lazy-img demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.