npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hlg-angular-lazy-img

v1.2.0

Published

Plugin for lazy loading images in Angular

Downloads

19

Readme

angular-lazy-img

Lightweight lazy load images plugin. Only 1kb after gziping. Pure JavaScript, only Angular as dependency.

Installation

  1. bower install --save angular-lazy-img

  2. Include angular-lazy-img in your HTML.

    <script src="<your-bower-components>/angular-lazy-img/release/angular-lazy-img.js"></script>
  3. Inject the angular-lazy-img module in your application.

    angular.module('your.module', [
        'angularLazyImg'
    ]);

Usage

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

Configuration

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
  });
}])

Use a scrollable container in a dynamic page

Just add lazyImgContainer attribute to your scrollable container to be considered when you scroll him.

Author

Copyright 2014, Paweł Wszoła ([email protected])