Fix sticky sidebar
This commit is contained in:
parent
458e262a26
commit
f997280ab1
2 changed files with 4 additions and 4 deletions
|
|
@ -119,11 +119,11 @@ export function scroll2Top (offset = 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sticky () {
|
export function sticky () {
|
||||||
const dom = document.querySelector('section.cover')
|
sticky.dom = sticky.dom || document.querySelector('section.cover')
|
||||||
const coverHeight = dom.getBoundingClientRect().height
|
const coverHeight = sticky.dom.getBoundingClientRect().height
|
||||||
|
|
||||||
return (function () {
|
return (function () {
|
||||||
if (window.pageYOffset >= coverHeight || dom.classList.contains('hidden')) {
|
if (window.pageYOffset >= coverHeight || sticky.dom.classList.contains('hidden')) {
|
||||||
document.body.classList.add('sticky')
|
document.body.classList.add('sticky')
|
||||||
sticky.noSticky = false
|
sticky.noSticky = false
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ export function renderCover (content) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
renderCover.dom.classList.add('show')
|
renderCover.dom.classList.add('show')
|
||||||
if (renderCover.rendered) return
|
if (renderCover.rendered) return event.sticky()
|
||||||
|
|
||||||
// render cover
|
// render cover
|
||||||
let html = markdown(content)
|
let html = markdown(content)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue