Update layout.pug

This commit is contained in:
Jerry Wong
2025-11-25 14:52:42 +08:00
committed by GitHub
Unverified
parent 57a7db7a52
commit 8ae57ac9bf

View File

@@ -23,18 +23,18 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
const arr = !{JSON.stringify(bgStyleArr)} const arr = !{JSON.stringify(bgStyleArr)}
const webBgDiv = document.getElementById('web_bg') const webBgDiv = document.getElementById('web_bg')
function setRandomBg() { const setRandomBg = () => {
webBgDiv.style = arr[Math.floor(Math.random() * arr.length)] webBgDiv.style = arr[Math.floor(Math.random() * arr.length)]
requestAnimationFrame(() => webBgDiv.classList.add('bg-animation'))
} }
setRandomBg()
document.addEventListener('pjax:send', () => { document.addEventListener('pjax:send', () => {
setRandomBg() webBgDiv.style = ''
// Reload CSS animation
webBgDiv.classList.remove('bg-animation') webBgDiv.classList.remove('bg-animation')
void webBgDiv.offsetWidth
webBgDiv.classList.add('bg-animation')
}) })
document.addEventListener('pjax:complete', setRandomBg)
document.addEventListener('DOMContentLoaded', setRandomBg)
})() })()
!=partial('includes/sidebar', {}, {cache: true}) !=partial('includes/sidebar', {}, {cache: true})