feat: lazy load widgets and modal sections, fix transition on settings modal

This commit is contained in:
David Ralph
2021-04-11 11:17:09 +01:00
parent 149bcdbe05
commit 465596d22d
7 changed files with 56 additions and 26 deletions

View File

@@ -71,8 +71,11 @@ export default class Background extends React.PureComponent {
const backgroundImage = document.querySelector('#backgroundImage');
backgroundImage.classList.add('backgroundPreload');
// preloader for background transition
let preloader = document.createElement('img');
preloader.src = url;
// once image has loaded, add the fade-in transition
preloader.addEventListener('load', () => {
backgroundImage.classList.remove('backgroundPreload');
backgroundImage.classList.add('fade-in');
@@ -82,6 +85,13 @@ export default class Background extends React.PureComponent {
`background-image: url(${url}); -webkit-filter: blur(${localStorage.getItem('blur')}px) brightness(${brightness}%);`
);
preloader = null;
// wait before showing photoinformation, should make this better with state or something later but lazy
if (this.state.photoInfo.hidden === false) {
setTimeout(() => {
document.querySelector('.photoInformation').style.display = 'block';
}, 800);
}
});
} else {
document.querySelector('#backgroundImage').setAttribute(