Skip to content

Commit 17d7b5c

Browse files
authored
fix: revert scoll but workaround and use document.body.scrollTop (#54)
1 parent 5c0eaa6 commit 17d7b5c

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

assets/index.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ function main() {
2727
return
2828
}
2929

30-
// layout
30+
// setup the layout
3131
configureFileSelect()
3232
addIncrementalButton()
3333
addThemeButton()
3434

35+
// setup the content
3536
configureCodeBlocks()
3637
configureSyntaxHighlight('pre .code .editor')
3738
addCoverageSpans('pre .coverage .editor')
@@ -113,16 +114,11 @@ function configureFileSelect() {
113114
}
114115

115116
document.location.hash = e.target.value
116-
document.querySelectorAll('.file').forEach((el) => (el.style.display = 'none'))
117-
el.style.display = 'block'
118117

119-
let scrollUp = (times) => {
120-
if (window.scrollY === 0 && times > 3) return
121-
window.scrollTo(0, 0)
122-
window.requestAnimationFrame(() => scrollUp(times + 1))
123-
}
118+
document.body.scrollTop = 0;
124119

125-
scrollUp(1)
120+
document.querySelectorAll('.file').forEach((el) => (el.style.display = 'none'))
121+
el.style.display = 'block'
126122
})
127123

128124
files.value = selected

0 commit comments

Comments
 (0)