mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2026-11-20 18:37:50 +01:00
Add list dynamic background
This commit is contained in:
1 parent
1b6c1399bb
commit
ee1f7e5aee
3 files changed
+28
-1
No files matched your search
@@ -0,0 +1,24 @@
|
||||
hljs.initHighlightingOnLoad();
|
||||
|
||||
const listBg = document.querySelector('.list-bg');
|
||||
|
||||
if (listBg) {
|
||||
const halfAnHour = 1000 * 60 * 30;
|
||||
|
||||
function setListBgStyle() {
|
||||
const now = new Date();
|
||||
const time = now.getHours() + now.getMinutes() / 60;
|
||||
|
||||
let opacity = Math.abs(time - 14);
|
||||
opacity = opacity > 12 ? 10 + Math.abs(opacity - 14) : opacity;
|
||||
opacity = Number((opacity / 12).toFixed(2));
|
||||
|
||||
listBg.setAttribute('style', `opacity: ${opacity}`);
|
||||
}
|
||||
|
||||
requestAnimationFrame(setListBgStyle);
|
||||
|
||||
setInterval(() => {
|
||||
requestAnimationFrame(setListBgStyle);
|
||||
}, halfAnHour);
|
||||
}
|
||||
Reference in new issue
Block a user