@@ -508,9 +508,7 @@ export default class Table extends React.Component {
508
508
className = { `${ prefixCls } -header` }
509
509
ref = { fixed ? null : 'headTable' }
510
510
style = { headStyle }
511
- onMouseOver = { this . detectScrollTarget }
512
- onTouchStart = { this . detectScrollTarget }
513
- onScroll = { this . handleBodyScroll }
511
+ onScroll = { this . handleBodyScrollLeft }
514
512
>
515
513
{ renderTable ( true , false ) }
516
514
</ div >
@@ -523,8 +521,6 @@ export default class Table extends React.Component {
523
521
className = { `${ prefixCls } -body` }
524
522
style = { bodyStyle }
525
523
ref = "bodyTable"
526
- onMouseOver = { this . detectScrollTarget }
527
- onTouchStart = { this . detectScrollTarget }
528
524
onScroll = { this . handleBodyScroll }
529
525
>
530
526
{ renderTable ( ! useFixedHeader ) }
@@ -550,8 +546,6 @@ export default class Table extends React.Component {
550
546
className = { `${ prefixCls } -body-inner` }
551
547
style = { innerBodyStyle }
552
548
ref = { refName }
553
- onMouseOver = { this . detectScrollTarget }
554
- onTouchStart = { this . detectScrollTarget }
555
549
onScroll = { this . handleBodyScroll }
556
550
>
557
551
{ renderTable ( ! useFixedHeader ) }
@@ -686,46 +680,50 @@ export default class Table extends React.Component {
686
680
return typeof this . findExpandedRow ( record , index ) !== 'undefined' ;
687
681
}
688
682
689
- detectScrollTarget = ( e ) => {
690
- if ( this . scrollTarget !== e . currentTarget ) {
691
- this . scrollTarget = e . currentTarget ;
692
- }
693
- }
694
-
695
683
hasScrollX ( ) {
696
684
const { scroll = { } } = this . props ;
697
685
return 'x' in scroll ;
698
686
}
699
687
700
- handleBodyScroll = ( e ) => {
701
- // Prevent scrollTop setter trigger onScroll event
702
- // http://stackoverflow.com/q/1386696
703
- if ( e . target !== this . scrollTarget ) {
704
- return ;
705
- }
688
+ handleBodyScrollLeft = ( e ) => {
689
+ const target = e . target ;
706
690
const { scroll = { } } = this . props ;
707
- const { headTable, bodyTable, fixedColumnsBodyLeft , fixedColumnsBodyRight } = this . refs ;
708
- if ( scroll . x && e . target . scrollLeft !== this . lastScrollLeft ) {
709
- if ( e . target === bodyTable && headTable ) {
710
- headTable . scrollLeft = e . target . scrollLeft ;
711
- } else if ( e . target === headTable && bodyTable ) {
712
- bodyTable . scrollLeft = e . target . scrollLeft ;
691
+ const { headTable, bodyTable } = this . refs ;
692
+ if ( target . scrollLeft !== this . lastScrollLeft && scroll . x ) {
693
+ if ( target === bodyTable && headTable ) {
694
+ headTable . scrollLeft = target . scrollLeft ;
695
+ } else if ( target === headTable && bodyTable ) {
696
+ bodyTable . scrollLeft = target . scrollLeft ;
713
697
}
714
- this . setScrollPositionClassName ( e . target ) ;
698
+ this . setScrollPositionClassName ( target ) ;
715
699
}
716
- if ( scroll . y ) {
717
- if ( fixedColumnsBodyLeft && e . target !== fixedColumnsBodyLeft ) {
718
- fixedColumnsBodyLeft . scrollTop = e . target . scrollTop ;
700
+ // Remember last scrollLeft for scroll direction detecting.
701
+ this . lastScrollLeft = target . scrollLeft ;
702
+ }
703
+
704
+ handleBodyScrollTop = ( e ) => {
705
+ const target = e . target ;
706
+ const { scroll = { } } = this . props ;
707
+ const { headTable, bodyTable, fixedColumnsBodyLeft, fixedColumnsBodyRight } = this . refs ;
708
+ if ( target . scrollTop !== this . lastScrollTop && scroll . y && target !== headTable ) {
709
+ const scrollTop = target . scrollTop ;
710
+ if ( fixedColumnsBodyLeft && target !== fixedColumnsBodyLeft ) {
711
+ fixedColumnsBodyLeft . scrollTop = scrollTop ;
719
712
}
720
- if ( fixedColumnsBodyRight && e . target !== fixedColumnsBodyRight ) {
721
- fixedColumnsBodyRight . scrollTop = e . target . scrollTop ;
713
+ if ( fixedColumnsBodyRight && target !== fixedColumnsBodyRight ) {
714
+ fixedColumnsBodyRight . scrollTop = scrollTop ;
722
715
}
723
- if ( bodyTable && e . target !== bodyTable ) {
724
- bodyTable . scrollTop = e . target . scrollTop ;
716
+ if ( bodyTable && target !== bodyTable ) {
717
+ bodyTable . scrollTop = scrollTop ;
725
718
}
726
719
}
727
- // Remember last scrollLeft for scroll direction detecting.
728
- this . lastScrollLeft = e . target . scrollLeft ;
720
+ // Remember last scrollTop for scroll direction detecting.
721
+ this . lastScrollTop = target . scrollTop ;
722
+ }
723
+
724
+ handleBodyScroll = ( e ) => {
725
+ this . handleBodyScrollLeft ( e ) ;
726
+ this . handleBodyScrollTop ( e ) ;
729
727
}
730
728
731
729
handleRowHover = ( isHover , key ) => {
0 commit comments