fix: 修復開啟anchor後,瀏覽器上一頁/下一頁 跳轉會404的bug (文章頁的url hash 在pjax下變成 undefined)

fix: 修復開啟anchor後,文章頁跳轉回主頁,主頁網址的hash添加上文章頁最後一個標題的 bug
improvement: 優化 button tags 標簽外掛
This commit is contained in:
Jerry
2021-04-23 18:06:51 +08:00
parent c48ce9af8c
commit 597f0d2019
7 changed files with 52 additions and 29 deletions

View File

@@ -11,6 +11,9 @@
color: $btn-color
line-height: 2
i + span
margin-left: .3rem
&:not(.block) + .btn-beautify:not(.block)
margin: 0 .2rem 1rem

View File

@@ -388,11 +388,14 @@ document.addEventListener('DOMContentLoaded', function () {
const $article = document.getElementById('article-container')
// main of scroll
window.addEventListener('scroll', btf.throttle(function (e) {
const currentTop = window.scrollY || document.documentElement.scrollTop
scrollPercent(currentTop)
findHeadPosition(currentTop)
}, 100))
window.tocScrollFn = function () {
return btf.throttle(function () {
const currentTop = window.scrollY || document.documentElement.scrollTop
scrollPercent(currentTop)
findHeadPosition(currentTop)
}, 100)()
}
window.addEventListener('scroll', tocScrollFn)
const scrollPercent = function (currentTop) {
const docHeight = $article.clientHeight