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

angular-imagesloaded

v1.0.0

Published

:camera: AngularJS integration for the imagesloaded library.

Downloads

14

Readme

angular-imagesloaded

MIT License NPM version Coverage Status CircleCI

:camera: :white_check_mark: AngularJS integration for the imagesloaded library.

:tv: Demos and Examples

Comments and Pull Requests welcome!

Contents

Installation

NPM

npm install angular-imagesloaded --save

Bower

bower install angular-imagesloaded --save

Manual

<script src="path/to/lib/dist/angular-imagesloaded.min.js"></script>

Dependencies

  • Angular.js (^1.4.0)
  • imagesloaded (^4.1.1)

Usage

Include bc.imagesloaded as a dependency in your project:

angular.module('YourModule', ['bc.imagesloaded']);

bc-imagesloaded

Use this directive directly on an image as an attribute to create an imagesloaded instance for that specific image:

<img
  src="http://lorempixel.com/400/300"
  bc-imagesloaded
  alt=""
/>

:tv: Element usage demo

You can also pass in a selector string, NodeList or array to target multiple child elements:

<div bc-imagesloaded=".test">
  <img
    class="test"
    src="http://lorempixel.com/400/300"
    alt=""
  />
  <img
    class="test"
    src="http://lorempixel.com/400/300"
    alt=""
  />
</div>

:tv: Selector string demo

bc-background

Set this attribute to true to enable imagesloaded on the background of the current element:

<div
  bc-imagesloaded
  bc-background="true"
  style="background-image: url(http://lorempixel.com/400/300)"
></div>

You can also pass in a selector string to enable imagesloaded on multiple child elements:

<div
  bc-imagesloaded
  bc-background=".test"
>
  <div
    class="test"
    style="background-image: url(http://lorempixel.com/400/300)"
  ></div>
  <div
    class="test"
    style="background-image: url(http://lorempixel.com/400/300)"
  ></div>
</div>

:tv: Background image demo

'bc-debug'

When this attribute is set to true, imagesloaded will output debug logs to the console.

<img
  src="http://lorempixel.com/400/300"
  bc-imagesloaded
  bc-debug="true"
  alt=""
/>

:tv: Debug flag demo

Events

Events can help ....

Always

Triggered after all images have been either loaded or confirmed broken.

Available Parameters:

| Param | Type | Details | |-------|------|---------| | instance | Object | The imagesLoaded instance |

<div
  bc-imagesloaded=".image"
  bc-always-method="vm.yourAlwaysMethod(instance)"
>
  <img class="image" src="http://lorempixel.com/100/100" alt="" />
  <img class="image" src="http://lorempixel.com/100/100" alt="" />
  <img class="image" src="image/does/not/exist.jpg" alt="" />
</div>
class YourController {

  constructor() {}

  // This method will be called after all images are either loaded or confirmed broken
  yourAlwaysMethod(instance) {
    console.log('Images finished! Instance: ', instance)
  }

}

:tv: Always event demo

Done

Triggered after all images have successfully loaded without any broken images.

Available Parameters:

| Param | Type | Details | |-------|------|---------| | instance | Object | The imagesLoaded instance |

<div
  bc-imagesloaded=".image"
  bc-always-method="vm.yourDoneMethod(instance)"
>
  <img class="image" src="http://lorempixel.com/100/100" alt="" />
  <img class="image" src="http://lorempixel.com/100/100" alt="" />
</div>
class YourController {

  constructor() {}

  // This method will be called after all images have loaded successfully
  yourDoneMethod(instance) {
    console.log('All images loaded successfully! Instance: ', instance)
  }

}

:tv: Done event demo

Fail

Triggered after all images have been loaded with at least one broken image.

Available Parameters:

| Param | Type | Details | |-------|------|---------| | instance | Object | The imagesLoaded instance |

<div
  bc-imagesloaded=".image"
  bc-always-method="vm.yourFailMethod(instance)"
>
  <img class="image" src="http://lorempixel.com/100/100" alt="" />
  <img class="image" src="http://lorempixel.com/100/100" alt="" />
  <img class="image" src="image/does/not/exist.jpg" alt="" />
</div>
class YourController {

  constructor() {}

  // This method will be called after all images have loaded and at least one is broken
  yourFailMethod(instance) {
    console.log('All images loaded; at least one is broken! Instance: ', instance)
  }

}

:tv: Fail event demo

Progress

Triggered after each image has been loaded.

Available Parameters:

| Param | Type | Details | |-------|------|---------| | instance | Object | The imagesLoaded instance | | image | Object | The LoadingImage instance of the loaded image |

<div
  bc-imagesloaded=".image"
  bc-always-method="vm.yourProgressMethod(instance, image)"
>
  <img class="image" src="http://lorempixel.com/100/100" alt="" />
  <img class="image" src="http://lorempixel.com/100/100" alt="" />
</div>
class YourController {

  constructor() {}

  // This method will be called after EACH image is loaded
  yourProgressMethod(instance, image) {
    console.log('An image was loaded! Instance: ', instance, ' Image: ', image)
  }

}

:tv: Progress event demo

Development

  • npm run build - Build JS
  • npm run watch - Watch JS and rebuild on change
  • npm run test - Run tests
  • npm run watch:tests - Watch test files and re-run tests on change

About imagesloaded

JavaScript is all like "You images done yet or what?"

Created by David DeSandro.