mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
Update layout.pug
This commit is contained in:
@@ -23,18 +23,18 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
|
||||
const arr = !{JSON.stringify(bgStyleArr)}
|
||||
const webBgDiv = document.getElementById('web_bg')
|
||||
|
||||
function setRandomBg() {
|
||||
const setRandomBg = () => {
|
||||
webBgDiv.style = arr[Math.floor(Math.random() * arr.length)]
|
||||
requestAnimationFrame(() => webBgDiv.classList.add('bg-animation'))
|
||||
}
|
||||
|
||||
setRandomBg()
|
||||
document.addEventListener('pjax:send', () => {
|
||||
setRandomBg()
|
||||
// Reload CSS animation
|
||||
webBgDiv.style = ''
|
||||
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})
|
||||
@@ -56,4 +56,4 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
|
||||
!=partial('includes/footer', {}, {cache: true})
|
||||
|
||||
include ./rightside.pug
|
||||
include ./additional-js.pug
|
||||
include ./additional-js.pug
|
||||
|
||||
Reference in New Issue
Block a user