Add image fade functionality
This commit is contained in:
19
js/imagefade.js
Normal file
19
js/imagefade.js
Normal 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user