Skip to content

Commit

Permalink
fix: 返回顶部按钮触发不丝滑
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed Sep 7, 2022
1 parent d452b56 commit 8d086f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
5 changes: 3 additions & 2 deletions packages/website/components/BackToTop/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
import style from "../../styles/back-to-top.module.css";
import { scrollTo } from "../../utils/scroll";
import { debounce } from "../../utils/debounce";
import throttle from "lodash/throttle";
interface BackToTopBtnProps {}
function getScrollTop() {
var scrollTop = 0,
Expand All @@ -25,7 +25,8 @@ const BackToTopBtn: React.FC<BackToTopBtnProps> = (props) => {
return () => document.removeEventListener("scroll", handleScroll, true);
}, [visibleBackTopBtn]);

const handleScroll = debounce((ev: any) => {
const handleScroll = throttle((ev: any) => {
console.log("scroll");
ev.stopPropagation();
ev.preventDefault();
const scrollTop = getScrollTop();
Expand Down
10 changes: 0 additions & 10 deletions packages/website/utils/debounce.ts

This file was deleted.

0 comments on commit 8d086f2

Please sign in to comment.