perf: debounce handleOsScroll (#735)

* fix: debounce handleOsScroll in OverlayScrollbarsComponent

* fix: 改成箭头函数写法

* refactor: use `useDebounceFn` for debounce handleOsScroll

---------

Co-authored-by: pengyunfei <pengyunfei@360.cn>
This commit is contained in:
Hakadao
2024-05-09 00:21:05 +08:00
committed by GitHub
parent 9daabd55db
commit a7488c188e

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { useThrottleFn, useToggle } from '@vueuse/core'
import { useDebounceFn, useThrottleFn, useToggle } from '@vueuse/core'
import type { Ref } from 'vue'
import { useI18n } from 'vue-i18n'
import browser from 'webextension-polyfill'
@@ -196,7 +196,7 @@ function handleAdaptToOtherPageStylesChange() {
document.documentElement.classList.remove('bewly-design')
}
function handleOsScroll() {
const handleOsScroll = useDebounceFn(() => {
const osInstance = scrollbarRef.value?.osInstance()
const { viewport } = osInstance.elements()
const { scrollTop, scrollHeight, clientHeight } = viewport // get scroll offset
@@ -211,7 +211,7 @@ function handleOsScroll() {
if (isHomePage())
topBarRef.value?.handleScroll()
}
}, 50)
function handleBlockAds() {
// Do not use the "ads" keyword. AdGuard, AdBlock, and some ad-blocking extensions will