mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 15:09:22 +00:00
微调
This commit is contained in:
@@ -16,8 +16,9 @@ const JumpToTop = ({ targetRef, showPercent = true }) => {
|
||||
const [percent, changePercent] = useState(0)
|
||||
const scrollListener = useCallback(throttle(() => {
|
||||
// 处理是否显示回到顶部按钮
|
||||
const clientHeight = targetRef ? (targetRef.current.clientHeight) : 0
|
||||
const scrollY = window.pageYOffset
|
||||
const fullHeight = targetRef.current.clientHeight - window.outerHeight
|
||||
const fullHeight = clientHeight - window.outerHeight
|
||||
const shouldShow = scrollY > 100
|
||||
if (shouldShow !== show) {
|
||||
switchShow(shouldShow)
|
||||
|
||||
@@ -10,8 +10,9 @@ const Progress = ({ targetRef }) => {
|
||||
const [percent, changePercent] = useState(0)
|
||||
const scrollListener = useCallback(throttle(() => {
|
||||
if (targetRef.current) {
|
||||
const clientHeight = targetRef ? (targetRef.current.clientHeight) : 0
|
||||
const scrollY = window.pageYOffset
|
||||
const fullHeight = targetRef.current.clientHeight - window.outerHeight
|
||||
const fullHeight = clientHeight - window.outerHeight
|
||||
let per = parseFloat(((scrollY / fullHeight * 100)).toFixed(0))
|
||||
if (per > 100) per = 100
|
||||
changePercent(per)
|
||||
|
||||
Reference in New Issue
Block a user