We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc2cb8b commit 0ba33e4Copy full SHA for 0ba33e4
src/components/StickyList.js
@@ -16,12 +16,18 @@ function StickyList(
16
) {
17
const innerRef = useRef();
18
useEffect(() => {
19
- if (ref.current && innerRef.current) {
20
- if (mode === 'bottom') {
21
- ref.current.scrollTo(innerRef.current.offsetHeight);
22
- } else if (mode === 'top') {
23
- ref.current.scrollTo(0);
24
- }
+ if (!ref.current || !innerRef.current) {
+ return;
+ }
+
+ if (innerRef.current.offsetHeight <= ref.current.props.height) {
25
26
27
+ if (mode === 'bottom') {
28
+ ref.current.scrollTo(innerRef.current.offsetHeight);
29
+ } else {
30
+ ref.current.scrollTo(0);
31
}
32
}, [itemCount]);
33
0 commit comments