Add image fade functionality

This commit is contained in:
2018-03-07 15:25:54 +00:00
parent e9b30d963b
commit ac586d122c
4 changed files with 59 additions and 3 deletions

19
js/imagefade.js Normal file
View File

@@ -0,0 +1,19 @@
export default class ImageFade {
constructor() {
this.images = Array.prototype.slice.call(document.querySelectorAll('img'));
this.images.forEach((image) => {
this.prepareImage(image);
this.setEvent(image);
});
}
prepareImage(image) {
image.style.opacity = 0;
}
setEvent(image) {
image.addEventListener('load', () => {
image.style.opacity = 1;
});
}
}