@@ -508,9 +508,7 @@ export default class Table extends React.Component {
508508 className = { `${ prefixCls } -header` }
509509 ref = { fixed ? null : 'headTable' }
510510 style = { headStyle }
511- onMouseOver = { this . detectScrollTarget }
512- onTouchStart = { this . detectScrollTarget }
513- onScroll = { this . handleBodyScroll }
511+ onScroll = { this . handleBodyScrollLeft }
514512 >
515513 { renderTable ( true , false ) }
516514 </ div >
@@ -523,8 +521,6 @@ export default class Table extends React.Component {
523521 className = { `${ prefixCls } -body` }
524522 style = { bodyStyle }
525523 ref = "bodyTable"
526- onMouseOver = { this . detectScrollTarget }
527- onTouchStart = { this . detectScrollTarget }
528524 onScroll = { this . handleBodyScroll }
529525 >
530526 { renderTable ( ! useFixedHeader ) }
@@ -550,8 +546,6 @@ export default class Table extends React.Component {
550546 className = { `${ prefixCls } -body-inner` }
551547 style = { innerBodyStyle }
552548 ref = { refName }
553- onMouseOver = { this . detectScrollTarget }
554- onTouchStart = { this . detectScrollTarget }
555549 onScroll = { this . handleBodyScroll }
556550 >
557551 { renderTable ( ! useFixedHeader ) }
@@ -686,46 +680,50 @@ export default class Table extends React.Component {
686680 return typeof this . findExpandedRow ( record , index ) !== 'undefined' ;
687681 }
688682
689- detectScrollTarget = ( e ) => {
690- if ( this . scrollTarget !== e . currentTarget ) {
691- this . scrollTarget = e . currentTarget ;
692- }
693- }
694-
695683 hasScrollX ( ) {
696684 const { scroll = { } } = this . props ;
697685 return 'x' in scroll ;
698686 }
699687
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 ;
706690 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 ;
713697 }
714- this . setScrollPositionClassName ( e . target ) ;
698+ this . setScrollPositionClassName ( target ) ;
715699 }
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 ;
719712 }
720- if ( fixedColumnsBodyRight && e . target !== fixedColumnsBodyRight ) {
721- fixedColumnsBodyRight . scrollTop = e . target . scrollTop ;
713+ if ( fixedColumnsBodyRight && target !== fixedColumnsBodyRight ) {
714+ fixedColumnsBodyRight . scrollTop = scrollTop ;
722715 }
723- if ( bodyTable && e . target !== bodyTable ) {
724- bodyTable . scrollTop = e . target . scrollTop ;
716+ if ( bodyTable && target !== bodyTable ) {
717+ bodyTable . scrollTop = scrollTop ;
725718 }
726719 }
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 ) ;
729727 }
730728
731729 handleRowHover = ( isHover , key ) => {
0 commit comments