Skip to content

Commit 6828f62

Browse files
committed
fix(InnerScroll): top position
1 parent 94638fd commit 6828f62

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/scroll/inner-scroll.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22
import { usePathname } from 'next/navigation';
3-
import React, { createRef, useEffect } from 'react';
3+
import React, { useEffect, useRef } from 'react';
44
import { InnerScrollEvent } from '.';
55
import useClasses from '../use-classes';
66
import useScale, { withScale } from '../use-scale';
@@ -25,7 +25,7 @@ const InnerScrollComponent: React.FC<React.PropsWithChildren<InnerScrollProps>>
2525
...props
2626
}) => {
2727
const { UNIT, SCALE, CLASS_NAMES } = useScale();
28-
const ref = createRef<HTMLDivElement>();
28+
const ref = useRef<HTMLDivElement>(null);
2929
const pathName = usePathname();
3030

3131
const onScrollHandler = () => {
@@ -38,7 +38,7 @@ const InnerScrollComponent: React.FC<React.PropsWithChildren<InnerScrollProps>>
3838
useEffect(() => {
3939
if (scrollUpOnRouteChange) {
4040
ref?.current?.scrollTo({
41-
top: 0,
41+
top: ref.current.scrollTop,
4242
behavior: 'instant',
4343
});
4444
}

0 commit comments

Comments
 (0)