File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 42
42
"dotenv" : " ^16.4.5" ,
43
43
"feed" : " ^4.2.2" ,
44
44
"giscus" : " ^1.5.0" ,
45
+ "lodash.debounce" : " ^4.0.8" ,
45
46
"mdast-util-to-string" : " ^4.0.0" ,
46
47
"nanostores" : " ^0.10.3" ,
47
48
"object-treeify" : " ^4.0.1" ,
60
61
"@iconify-json/mdi" : " ^1.1.66" ,
61
62
"@tailwindcss/typography" : " ^0.5.13" ,
62
63
"@types/debounce" : " ^1.2.4" ,
64
+ "@types/lodash.debounce" : " ^4.0.9" ,
63
65
"@types/mdast" : " ^4.0.3" ,
64
66
"@types/react" : " ^18.3.3" ,
65
67
"@types/react-dom" : " ^18.3.0" ,
Original file line number Diff line number Diff line change 1
1
import React , { useEffect , useRef , useState } from 'react' ;
2
2
3
+ import debounce from 'lodash.debounce' ;
4
+
3
5
import { cn } from '@/utils/styles' ;
4
6
5
7
import type { ReactNode } from 'react' ;
@@ -53,7 +55,8 @@ const ScrollToTop: React.FC<Props> = ({ children }) => {
53
55
}
54
56
} ;
55
57
56
- const intersect = new IntersectionObserver ( callback ) ;
58
+ const debouncedCallback = debounce ( callback , 500 ) ;
59
+ const intersect = new IntersectionObserver ( debouncedCallback ) ;
57
60
58
61
if ( topRef . current ) intersect . observe ( topRef . current ) ;
59
62
if ( bottomRef . current ) intersect . observe ( bottomRef . current ) ;
Original file line number Diff line number Diff line change 1115
1115
resolved "https://registry.yarnpkg.com/@types/is-empty/-/is-empty-1.2.3.tgz#a2d55ea8a5ec57bf61e411ba2a9e5132fe4f0899"
1116
1116
integrity sha512-4J1l5d79hoIvsrKh5VUKVRA1aIdsOb10Hu5j3J2VfP/msDnfTdGPmNp2E1Wg+vs97Bktzo+MZePFFXSGoykYJw==
1117
1117
1118
+ " @types/lodash.debounce@^4.0.9 " :
1119
+ version "4.0.9"
1120
+ resolved "https://registry.yarnpkg.com/@types/lodash.debounce/-/lodash.debounce-4.0.9.tgz#0f5f21c507bce7521b5e30e7a24440975ac860a5"
1121
+ integrity sha512-Ma5JcgTREwpLRwMM+XwBR7DaWe96nC38uCBDFKZWbNKD+osjVzdpnUSwBcqCptrp16sSOLBAUb50Car5I0TCsQ==
1122
+ dependencies :
1123
+ " @types/lodash" " *"
1124
+
1125
+ " @types/lodash@* " :
1126
+ version "4.17.7"
1127
+ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.7.tgz#2f776bcb53adc9e13b2c0dfd493dfcbd7de43612"
1128
+ integrity sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==
1129
+
1118
1130
" @types/mdast@^3.0.0 " :
1119
1131
version "3.0.15"
1120
1132
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.15.tgz#49c524a263f30ffa28b71ae282f813ed000ab9f5"
@@ -3944,6 +3956,11 @@ lodash.castarray@^4.4.0:
3944
3956
resolved "https://registry.yarnpkg.com/lodash.castarray/-/lodash.castarray-4.4.0.tgz#c02513515e309daddd4c24c60cfddcf5976d9115"
3945
3957
integrity sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==
3946
3958
3959
+ lodash.debounce@^4.0.8 :
3960
+ version "4.0.8"
3961
+ resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
3962
+ integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==
3963
+
3947
3964
lodash.isplainobject@^4.0.6 :
3948
3965
version "4.0.6"
3949
3966
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
You can’t perform that action at this time.
0 commit comments