Skip to content

Commit f997280

Browse files
committed
Fix sticky sidebar
1 parent 458e262 commit f997280

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/event.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ export function scroll2Top (offset = 0) {
119119
}
120120

121121
export function sticky () {
122-
const dom = document.querySelector('section.cover')
123-
const coverHeight = dom.getBoundingClientRect().height
122+
sticky.dom = sticky.dom || document.querySelector('section.cover')
123+
const coverHeight = sticky.dom.getBoundingClientRect().height
124124

125125
return (function () {
126-
if (window.pageYOffset >= coverHeight || dom.classList.contains('hidden')) {
126+
if (window.pageYOffset >= coverHeight || sticky.dom.classList.contains('hidden')) {
127127
document.body.classList.add('sticky')
128128
sticky.noSticky = false
129129
} else {

src/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export function renderCover (content) {
154154
return
155155
}
156156
renderCover.dom.classList.add('show')
157-
if (renderCover.rendered) return
157+
if (renderCover.rendered) return event.sticky()
158158

159159
// render cover
160160
let html = markdown(content)

0 commit comments

Comments
 (0)