Restore image fade in functionality
This commit is contained in:
18
js/image.js
Normal file
18
js/image.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export default class Image {
|
||||
constructor(image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
showImage() {
|
||||
this.image.style.opacity = 1;
|
||||
}
|
||||
|
||||
fadeIn() {
|
||||
this.image.style.opacity = 0;
|
||||
this.attachLoadedEvent();
|
||||
}
|
||||
|
||||
attachLoadedEvent() {
|
||||
this.image.addEventListener('load', () => this.showImage());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user