forked from extern/the-glorious-startpage
rename bodybackground to dummy, fix swipe event bug, improve transition of lazy loading
This commit is contained in:
parent
f0e192f14d
commit
420c498723
@ -1,6 +1,6 @@
|
||||
/*Filter for body's lazy loaded background */
|
||||
|
||||
#bodyBackground {
|
||||
#dummyBodyBackground {
|
||||
background: var(--base-body-bg);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@ -13,7 +13,11 @@
|
||||
transition: all 3s;
|
||||
}
|
||||
|
||||
.blurFiltered {
|
||||
.dummyBackgroundBlur {
|
||||
filter: blur(5px);
|
||||
-webkit-filter: blur(5px);
|
||||
}
|
||||
|
||||
.dummyBackgroundHide {
|
||||
opacity: 0;
|
||||
}
|
@ -34,7 +34,7 @@
|
||||
<body>
|
||||
|
||||
<!-- The place where we set the DUMMY background/image -->
|
||||
<div id='bodyBackground'></div>
|
||||
<div id='dummyBodyBackground'></div>
|
||||
|
||||
<div class='bar' id='topPanel'>
|
||||
<div id='clock'></div>
|
||||
|
@ -1,11 +1,11 @@
|
||||
class BodyBackground {
|
||||
class DummyBodyBackground {
|
||||
|
||||
constructor() {
|
||||
this._body = document.body;
|
||||
this._bodyBackground = document.querySelector('#bodyBackground');
|
||||
this._dummyBodyBackground = document.querySelector('#dummyBodyBackground');
|
||||
|
||||
this._bodyStyle = this._body.style;
|
||||
this._bodyBackgroundStyle = this._bodyBackground.style;
|
||||
this._dummyBodyBackgroundStyle = this._dummyBodyBackground.style;
|
||||
|
||||
this._hqBackground = document.createElement('img');
|
||||
|
||||
@ -24,10 +24,10 @@ class BodyBackground {
|
||||
_lazyLoadBackground = fileName => {
|
||||
|
||||
// Add a class to blur the dummy background
|
||||
this._bodyBackground.classList.add('blurFiltered');
|
||||
this._dummyBodyBackground.classList.add('dummyBackgroundBlur');
|
||||
|
||||
// Set a low quality background image for the dummy background
|
||||
this._styleBodyBackgrond(this._bodyBackgroundStyle, `url('assets/backgrounds/${fileName}-low.webp')`);
|
||||
this._styleBodyBackgrond(this._dummyBodyBackgroundStyle, `url('assets/backgrounds/${fileName}-low.webp')`);
|
||||
|
||||
// After loading/fetching the _hqBackground's background image
|
||||
this._hqBackground.onload = () => {
|
||||
@ -39,10 +39,10 @@ class BodyBackground {
|
||||
setTimeout (
|
||||
() => {
|
||||
// Hide the dummy background
|
||||
this._bodyBackgroundStyle.display = 'none';
|
||||
this._dummyBodyBackground.classList.add('dummyBackgroundHide');
|
||||
|
||||
// Remove class to unblur
|
||||
this._bodyBackground.classList.remove('blurFiltered');
|
||||
this._dummyBodyBackground.classList.remove('dummyBackgroundBlur');
|
||||
|
||||
},
|
||||
3000
|
||||
|
@ -63,7 +63,7 @@ class SwipeEventCallbacks extends SwipeEventManager {
|
||||
|
||||
// Assign swipe callback for each IDs
|
||||
_createSwipeEvents = () => {
|
||||
this.swipeEvent('bodyBackground', this._bodyBackgroundSwipeEvent);
|
||||
this.swipeEvent('dummyBodyBackground', this._bodyBackgroundSwipeEvent);
|
||||
|
||||
this.swipeEvent('rightDashboard', this._rightDashboardSwipeEvent);
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
// Instantiate config
|
||||
const config = new Config();
|
||||
|
||||
// Instantiate background setter
|
||||
const bodyBackground = new BodyBackground();
|
||||
// Instantiate dummy background setter
|
||||
const dummyBodyBackground = new DummyBodyBackground();
|
||||
|
||||
// Instantiate a clock object
|
||||
const clock = new Clock();
|
||||
|
Loading…
Reference in New Issue
Block a user