Repository: David-Desmaisons/Vue.ImagesLoaded
Branch: master
Commit: 97792cb429ec
Files: 28
Total size: 46.6 KB
Directory structure:
gitextract_gmn_0ea_/
├── .babelrc
├── .editorconfig
├── .gitignore
├── LICENSE
├── README.md
├── build/
│ ├── build.js
│ ├── check-versions.js
│ ├── dev-client.js
│ ├── dev-server.js
│ ├── utils.js
│ ├── webpack.base.conf.js
│ ├── webpack.dev.conf.js
│ └── webpack.prod.conf.js
├── config/
│ ├── dev.env.js
│ ├── index.js
│ └── prod.env.js
├── debug.log
├── dist/
│ └── vueimagesloaded.js
├── example/
│ ├── App.vue
│ ├── components/
│ │ └── Hello.vue
│ ├── index.html
│ ├── main.js
│ └── simple/
│ ├── css/
│ │ └── main.css
│ ├── index.html
│ └── js/
│ └── main.js
├── isObject.js
├── package.json
└── src/
└── imagesLoadedDirective.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .babelrc
================================================
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime", "add-module-exports", "transform-es2015-modules-umd"],
"comments": false
}
================================================
FILE: .editorconfig
================================================
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
================================================
FILE: .gitignore
================================================
.DS_Store
node_modules/
npm-debug.log
/example/simple/bower_components/
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2016 David Desmaisons
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Vue.ImagesLoaded
[](https://github.com/David-Desmaisons/Vue.ImagesLoaded/issues?q=is%3Aopen+is%3Aissue)
[](https://github.com/David-Desmaisons/Vue.ImagesLoaded/issues?q=is%3Aissue+is%3Aclosed)
[](https://www.npmjs.com/package/vue-images-loaded)
[](https://www.npmjs.com/package/vue-images-loaded)
[](https://vuejs.org/)
[](https://github.com/David-Desmaisons/Vue.ImagesLoaded/blob/master/LICENSE)
A Vue.js 2.0 directive to detect when images have been loaded, based on [imagesLoaded](http://imagesloaded.desandro.com/)
This directive allows to get a callback when children images are loaded in a container element.
Plays nicely with [vue.isotope](https://github.com/David-Desmaisons/Vue.Isotope) to allow re-layout when images are loaded.
## Demo

## Typical usage
```HTML
```
```javascript
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
```HTML
{{element.name}}
{{element.id}}
```
```javascript
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:
```HTML
```
Directive value:
```javascript
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:
```HTML
```
Directive value:
```javascript
listener:{
done(instance){
//...
},
fail(instance){
//...
}
}
```
listener is an `Object` containing callback functions.
Function should be named and will received arguments as described in [Imagesloaded](http://imagesloaded.desandro.com/)
- When used with `on` argument and modifier:
```HTML
```
Directive value:
```javascript
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:
``` js
npm install vue-images-loaded --save
```
``` js
bower install vue.ImagesLoaded -save
```
- #### For Modules
``` js
// ES6
import imagesLoaded from 'vue-images-loaded'
...
export default {
directives: {
imagesLoaded,
}
...
// ES5
var imagesLoaded = require('vue-images-loaded')
```
- #### For `
================================================
FILE: example/components/Hello.vue
================================================