mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 18:00:53 +08:00
Update layout.pug
This commit is contained in:
committed by
GitHub
Unverified
parent
57a7db7a52
commit
8ae57ac9bf
@@ -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})
|
||||||
@@ -56,4 +56,4 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
|
|||||||
!=partial('includes/footer', {}, {cache: true})
|
!=partial('includes/footer', {}, {cache: true})
|
||||||
|
|
||||||
include ./rightside.pug
|
include ./rightside.pug
|
||||||
include ./additional-js.pug
|
include ./additional-js.pug
|
||||||
|
|||||||
Reference in New Issue
Block a user