@@ -347,8 +347,8 @@ function Table<RecordType extends DefaultRecordType>(
347
347
348
348
// ====================== Scroll ======================
349
349
const scrollSummaryRef = React . useRef < HTMLDivElement > ( ) ;
350
- const [ pingedLeft , setPingedLeft ] = React . useState ( false ) ;
351
- const [ pingedRight , setPingedRight ] = React . useState ( false ) ;
350
+ const [ shadowStart , setShadowStart ] = React . useState ( false ) ;
351
+ const [ shadowEnd , setShadowEnd ] = React . useState ( false ) ;
352
352
const [ colsWidths , updateColsWidths ] = useLayoutState ( new Map < React . Key , number > ( ) ) ;
353
353
354
354
// Convert map to number width
@@ -440,7 +440,6 @@ function Table<RecordType extends DefaultRecordType>(
440
440
441
441
const onInternalScroll = useEvent (
442
442
( { currentTarget, scrollLeft } : { currentTarget : HTMLElement ; scrollLeft ?: number } ) => {
443
- const isRTL = direction === 'rtl' ;
444
443
const mergedScrollLeft =
445
444
typeof scrollLeft === 'number' ? scrollLeft : currentTarget . scrollLeft ;
446
445
@@ -463,24 +462,20 @@ function Table<RecordType extends DefaultRecordType>(
463
462
: measureTarget . scrollWidth ;
464
463
const clientWidth = measureTarget . clientWidth ;
465
464
465
+ const absScrollStart = Math . abs ( mergedScrollLeft ) ;
466
466
setScrollInfo ( ori => {
467
- const nextScrollInfo : ScrollInfoType = [ mergedScrollLeft , scrollWidth - clientWidth ] ;
467
+ const nextScrollInfo : ScrollInfoType = [ absScrollStart , scrollWidth - clientWidth ] ;
468
468
return isEqual ( ori , nextScrollInfo ) ? ori : nextScrollInfo ;
469
469
} ) ;
470
470
471
471
// There is no space to scroll
472
472
if ( scrollWidth === clientWidth ) {
473
- setPingedLeft ( false ) ;
474
- setPingedRight ( false ) ;
473
+ setShadowStart ( false ) ;
474
+ setShadowEnd ( false ) ;
475
475
return ;
476
476
}
477
- if ( isRTL ) {
478
- setPingedLeft ( - mergedScrollLeft < scrollWidth - clientWidth ) ;
479
- setPingedRight ( - mergedScrollLeft > 0 ) ;
480
- } else {
481
- setPingedLeft ( mergedScrollLeft > 0 ) ;
482
- setPingedRight ( mergedScrollLeft < scrollWidth - clientWidth ) ;
483
- }
477
+ setShadowStart ( absScrollStart > 0 ) ;
478
+ setShadowEnd ( absScrollStart < scrollWidth - clientWidth ) ;
484
479
}
485
480
} ,
486
481
) ;
@@ -497,8 +492,8 @@ function Table<RecordType extends DefaultRecordType>(
497
492
scrollLeft : scrollBodyRef . current ?. scrollLeft ,
498
493
} ) ;
499
494
} else {
500
- setPingedLeft ( false ) ;
501
- setPingedRight ( false ) ;
495
+ setShadowStart ( false ) ;
496
+ setShadowEnd ( false ) ;
502
497
}
503
498
} ;
504
499
@@ -771,8 +766,10 @@ function Table<RecordType extends DefaultRecordType>(
771
766
< div
772
767
className = { classNames ( prefixCls , className , {
773
768
[ `${ prefixCls } -rtl` ] : direction === 'rtl' ,
774
- [ `${ prefixCls } -ping-left` ] : pingedLeft ,
775
- [ `${ prefixCls } -ping-right` ] : pingedRight ,
769
+ [ `${ prefixCls } -fix-start-shadow` ] : horizonScroll ,
770
+ [ `${ prefixCls } -fix-end-shadow` ] : horizonScroll ,
771
+ [ `${ prefixCls } -fix-start-shadow-show` ] : horizonScroll && shadowStart ,
772
+ [ `${ prefixCls } -fix-end-shadow-show` ] : horizonScroll && shadowEnd ,
776
773
[ `${ prefixCls } -layout-fixed` ] : tableLayout === 'fixed' ,
777
774
[ `${ prefixCls } -fixed-header` ] : fixHeader ,
778
775
/** No used but for compatible */
0 commit comments