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

vue-images-loaded

v1.1.2

Published

Vue.js 2.0 directive to detect image loading

Downloads

13,011

Readme

Vue.ImagesLoaded

GitHub open issues GitHub closed issues Npm download Npm version vue2 MIT License

A Vue.js 2.0 directive to detect when images have been loaded, based on imagesLoaded

This directive allows to get a callback when children images are loaded in a container element. Plays nicely with vue.isotope to allow re-layout when images are loaded.

Demo

demo gif

Typical usage

<div v-images-loaded:on.progress="imageProgress">
	<div v-for="element in list">
		<img :src="element.src">
	</div>
</div>
import imagesLoaded from 'vue-images-loaded'

export default {
    directives: {
        imagesLoaded
    },
    methods: {
        imageProgress(instance, image ) {
        const result = image.isLoaded ? 'loaded' : 'broken';
        console.log( 'image is ' + result + ' for ' + image.img.src );
    }

Isotope Example

<isotope ref="cpt" :options='getOptions()' v-images-loaded:on.progress="layout" :list="list">
    <div v-for="element in list" :key="element.id"  @click="selected=element">
        {{element.name}}
        <br>
        {{element.id}}
        <img :src="element.src" alt="Not found">
    </div>
</isotope>
import imagesLoaded from 'vue-images-loaded'

export default {
    directives: {
        imagesLoaded
    },
    methods: {
        layout () {
            this.$refs.cpt.layout('masonry');
        }     
    }

API

Using directive

  • When used without argument nor modifiers:
<div v-images-loaded:"loaded">

Directive value:

function loaded(instance){
    //...
}

loaded is a Function triggered after all images have been either loaded or confirmed broken. Function parameter: ImagesLoaded instance

  • When used with on argument but no modifiers:
<div v-images-loaded.on:"listener">

Directive value:

listener:{
    done(instance){
        //...
    },
    fail(instance){
        //...
    }
}

listener is an Object containing callback functions. Function should be named and will received arguments as described in Imagesloaded

  • When used with on argument and modifier:
<div v-images-loaded.on.progress:"callback">

Directive value:

function callback(instance, img){
    //...
}

callback is a Function triggered acording to modifier name always, done, fail, progress. Function parameter: ImagesLoaded instance, and image information for progess only.

ImagesLoaded instance

  • Properties:
    • imagesLoaded.images

      Array of LoadingImage instances for each image detected

LoadingImage instance

  • Property:
    • LoadingImage.img

      Image - The img element

    • LoadingImage.isLoaded

      Boolean - true when the image has succesfully loaded

Installation

  • Available through bower and npm:
 npm install vue-images-loaded --save
 bower install vue.ImagesLoaded -save
  • For Modules

    // ES6
    import imagesLoaded from 'vue-images-loaded'
    ...
    export default {
          directives: {
              imagesLoaded,
          }
      ...
      
    // ES5
    var imagesLoaded = require('vue-images-loaded')
  • For <script> Include

    Just include vueimagesloaded.js after imagesloaded.pkgd.min.js script.