Skip to content

Commit 99a8785

Browse files
authored
fix: scroll top logic (#193)
* fix: scroll top logic * chore: bump ts
1 parent d2bc792 commit 99a8785

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"rc-animate": "^2.9.1",
6161
"react": "^v16.9.0-alpha.0",
6262
"react-dom": "^v16.9.0-alpha.0",
63-
"typescript": "^3.5.2"
63+
"typescript": "^4.0.0"
6464
},
6565
"dependencies": {
6666
"@babel/runtime": "^7.20.0",

src/hooks/useScrollTo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function useScrollTo<T>(
1717
): ScrollTo {
1818
const scrollRef = React.useRef<number>();
1919

20-
return arg => {
20+
return (arg) => {
2121
// When not argument provided, we think dev may want to show the scrollbar
2222
if (arg === null || arg === undefined) {
2323
triggerFlash();
@@ -36,7 +36,7 @@ export default function useScrollTo<T>(
3636
if ('index' in arg) {
3737
({ index } = arg);
3838
} else {
39-
index = data.findIndex(item => getKey(item) === arg.key);
39+
index = data.findIndex((item) => getKey(item) === arg.key);
4040
}
4141

4242
const { offset = 0 } = arg;
@@ -106,7 +106,7 @@ export default function useScrollTo<T>(
106106
collectHeight();
107107
}
108108
syncScroll(times - 1, newTargetAlign);
109-
});
109+
}, 2); // Delay 2 to wait for List collect heights
110110
};
111111

112112
syncScroll(3);

0 commit comments

Comments
 (0)