Skip to content

Commit ac33b5c

Browse files
committed
remove debounce from ScrollToTop
1 parent c8fb376 commit ac33b5c

File tree

3 files changed

+1
-37
lines changed

3 files changed

+1
-37
lines changed

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@
3838
"class-variance-authority": "^0.7.0",
3939
"clsx": "^2.1.1",
4040
"date-fns": "^3.6.0",
41-
"debounce": "^2.1.0",
4241
"dotenv": "^16.4.5",
4342
"feed": "^4.2.2",
4443
"giscus": "^1.5.0",
45-
"lodash.debounce": "^4.0.8",
4644
"mdast-util-to-string": "^4.0.0",
4745
"nanostores": "^0.10.3",
4846
"object-treeify": "^4.0.1",
@@ -62,8 +60,6 @@
6260
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
6361
"@iconify-json/mdi": "^1.1.66",
6462
"@tailwindcss/typography": "^0.5.13",
65-
"@types/debounce": "^1.2.4",
66-
"@types/lodash.debounce": "^4.0.9",
6763
"@types/mdast": "^4.0.3",
6864
"@types/react": "^18.3.3",
6965
"@types/react-dom": "^18.3.0",

src/components/react/ScrollToTop.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React, { useEffect, useRef, useState } from 'react';
22

3-
import debounce from 'lodash.debounce';
4-
53
import { cn } from '@/utils/styles';
64

75
import type { ReactNode } from 'react';
@@ -56,10 +54,7 @@ const ScrollToTop: React.FC<Props> = ({ children }) => {
5654
}
5755
};
5856

59-
// bellow 100 or it will break again on fast scroll
60-
// todo: set threshold and remove debounce
61-
const debouncedCallback = debounce(callback, 20);
62-
const intersect = new IntersectionObserver(debouncedCallback);
57+
const intersect = new IntersectionObserver(callback, { threshold: 0 });
6358

6459
if (topRef.current) intersect.observe(topRef.current);
6560
if (bottomRef.current) intersect.observe(bottomRef.current);

yarn.lock

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,11 +1214,6 @@
12141214
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.6.0.tgz#eac397f28bf1d6ae0ae081363eca2f425bedf0d5"
12151215
integrity sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==
12161216

1217-
"@types/debounce@^1.2.4":
1218-
version "1.2.4"
1219-
resolved "https://registry.yarnpkg.com/@types/debounce/-/debounce-1.2.4.tgz#cb7e85d9ad5ababfac2f27183e8ac8b576b2abb3"
1220-
integrity sha512-jBqiORIzKDOToaF63Fm//haOCHuwQuLa2202RK4MozpA6lh93eCBc+/8+wZn5OzjJt3ySdc+74SXWXB55Ewtyw==
1221-
12221217
"@types/debug@^4.0.0":
12231218
version "4.1.12"
12241219
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.12.tgz#a155f21690871953410df4b6b6f53187f0500917"
@@ -1250,18 +1245,6 @@
12501245
resolved "https://registry.yarnpkg.com/@types/is-empty/-/is-empty-1.2.3.tgz#a2d55ea8a5ec57bf61e411ba2a9e5132fe4f0899"
12511246
integrity sha512-4J1l5d79hoIvsrKh5VUKVRA1aIdsOb10Hu5j3J2VfP/msDnfTdGPmNp2E1Wg+vs97Bktzo+MZePFFXSGoykYJw==
12521247

1253-
"@types/lodash.debounce@^4.0.9":
1254-
version "4.0.9"
1255-
resolved "https://registry.yarnpkg.com/@types/lodash.debounce/-/lodash.debounce-4.0.9.tgz#0f5f21c507bce7521b5e30e7a24440975ac860a5"
1256-
integrity sha512-Ma5JcgTREwpLRwMM+XwBR7DaWe96nC38uCBDFKZWbNKD+osjVzdpnUSwBcqCptrp16sSOLBAUb50Car5I0TCsQ==
1257-
dependencies:
1258-
"@types/lodash" "*"
1259-
1260-
"@types/lodash@*":
1261-
version "4.17.7"
1262-
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.7.tgz#2f776bcb53adc9e13b2c0dfd493dfcbd7de43612"
1263-
integrity sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==
1264-
12651248
"@types/mdast@^3.0.0":
12661249
version "3.0.15"
12671250
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.15.tgz#49c524a263f30ffa28b71ae282f813ed000ab9f5"
@@ -2499,11 +2482,6 @@ date-fns@^3.6.0:
24992482
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-3.6.0.tgz#f20ca4fe94f8b754951b24240676e8618c0206bf"
25002483
integrity sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==
25012484

2502-
debounce@^2.1.0:
2503-
version "2.1.0"
2504-
resolved "https://registry.yarnpkg.com/debounce/-/debounce-2.1.0.tgz#eab25eaf254b848fcfccffbde75bdaa44842caa3"
2505-
integrity sha512-OkL3+0pPWCqoBc/nhO9u6TIQNTK44fnBnzuVtJAbp13Naxw9R6u21x+8tVTka87AhDZ3htqZ2pSSsZl9fqL2Wg==
2506-
25072485
25082486
version "2.6.9"
25092487
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -4125,11 +4103,6 @@ lodash.castarray@^4.4.0:
41254103
resolved "https://registry.yarnpkg.com/lodash.castarray/-/lodash.castarray-4.4.0.tgz#c02513515e309daddd4c24c60cfddcf5976d9115"
41264104
integrity sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==
41274105

4128-
lodash.debounce@^4.0.8:
4129-
version "4.0.8"
4130-
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
4131-
integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==
4132-
41334106
lodash.isplainobject@^4.0.6:
41344107
version "4.0.6"
41354108
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"

0 commit comments

Comments
 (0)