@@ -55,7 +55,7 @@ import TableContext from './context/TableContext';
55
55
import BodyContext from './context/BodyContext' ;
56
56
import Body from './Body' ;
57
57
import useColumns from './hooks/useColumns' ;
58
- import { useFrameState } from './hooks/useFrame' ;
58
+ import { useFrameState , useTimeoutLock } from './hooks/useFrame' ;
59
59
import { getPathValue , mergeObject , validateValue , newArr } from './utils/valueUtil' ;
60
60
import ResizeContext from './context/ResizeContext' ;
61
61
import useStickyOffsets from './hooks/useStickyOffsets' ;
@@ -344,6 +344,8 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
344
344
} ) ;
345
345
}
346
346
347
+ const [ setScrollTarget , getScrollTarget ] = useTimeoutLock ( null ) ;
348
+
347
349
function forceScroll ( scrollLeft : number , target : HTMLDivElement ) {
348
350
/* eslint-disable no-param-reassign */
349
351
if ( target && target . scrollLeft !== scrollLeft ) {
@@ -354,8 +356,13 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
354
356
355
357
const onScroll : React . UIEventHandler < HTMLDivElement > = ( { currentTarget } ) => {
356
358
const { scrollLeft, scrollWidth, clientWidth } = currentTarget ;
357
- forceScroll ( scrollLeft , scrollHeaderRef . current ) ;
358
- forceScroll ( scrollLeft , scrollBodyRef . current ) ;
359
+
360
+ if ( ! getScrollTarget ( ) || getScrollTarget ( ) === currentTarget ) {
361
+ setScrollTarget ( currentTarget ) ;
362
+
363
+ forceScroll ( scrollLeft , scrollHeaderRef . current ) ;
364
+ forceScroll ( scrollLeft , scrollBodyRef . current ) ;
365
+ }
359
366
360
367
setPingedLeft ( scrollLeft > 0 ) ;
361
368
setPingedRight ( scrollLeft < scrollWidth - clientWidth ) ;
0 commit comments