mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
修正throttle函数调用方式
只有在调用`throttle`返回的同一个对象时才能起到“节流”效果。
This commit is contained in:
@@ -277,8 +277,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
const isChatBtnHide = typeof chatBtnHide === 'function'
|
||||
const isChatBtnShow = typeof chatBtnShow === 'function'
|
||||
|
||||
window.scrollCollect = () => {
|
||||
return btf.throttle(function (e) {
|
||||
const scroolTask = btf.throttle(() => {
|
||||
const currentTop = window.scrollY || document.documentElement.scrollTop
|
||||
const isDown = scrollDirection(currentTop)
|
||||
if (currentTop > 56) {
|
||||
@@ -309,8 +308,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
if (document.body.scrollHeight <= innerHeight) {
|
||||
$rightside.style.cssText = 'opacity: 0.8; transform: translateX(-58px)'
|
||||
}
|
||||
}, 200)()
|
||||
}
|
||||
}, 200)
|
||||
|
||||
window.scrollCollect = scrollTask
|
||||
|
||||
window.addEventListener('scroll', scrollCollect)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user