@@ -130,6 +130,19 @@ var FixedDataTable = React.createClass({
130130 overflowX : PropTypes . oneOf ( [ 'hidden' , 'auto' ] ) ,
131131 overflowY : PropTypes . oneOf ( [ 'hidden' , 'auto' ] ) ,
132132
133+ /**
134+ * Hide the scrollbar but still enable scroll functionality
135+ */
136+ showScrollbarX : PropTypes . bool ,
137+ showScrollbarY : PropTypes . bool ,
138+
139+ /**
140+ * Callback when horizontally scrolling the grid
141+ *
142+ * Return false to stop propagation
143+ */
144+ onHorizontalScroll : PropTypes . func ,
145+
133146 /**
134147 * Number of rows in the table.
135148 */
@@ -258,8 +271,8 @@ var FixedDataTable = React.createClass({
258271 footerHeight : 0 ,
259272 groupHeaderHeight : 0 ,
260273 headerHeight : 0 ,
261- scrollLeft : 0 ,
262- scrollTop : 0 ,
274+ showScrollbarX : true ,
275+ showScrollbarY : true
263276 } ;
264277 } ,
265278
@@ -419,8 +432,8 @@ var FixedDataTable = React.createClass({
419432 }
420433
421434 var maxScrollY = this . state . maxScrollY ;
422- var showScrollbarX = state . maxScrollX > 0 && state . overflowX !== 'hidden' ;
423- var showScrollbarY = maxScrollY > 0 && state . overflowY !== 'hidden' ;
435+ var showScrollbarX = state . maxScrollX > 0 && state . overflowX !== 'hidden' && state . showScrollbarX !== false ;
436+ var showScrollbarY = maxScrollY > 0 && state . overflowY !== 'hidden' && state . showScrollbarY !== false ;
424437 var scrollbarXHeight = showScrollbarX ? Scrollbar . SIZE : 0 ;
425438 var scrollbarYHeight = state . height - scrollbarXHeight -
426439 ( 2 * BORDER_HEIGHT ) - state . footerHeight ;
@@ -748,14 +761,14 @@ var FixedDataTable = React.createClass({
748761 var firstRowIndex = ( oldState && oldState . firstRowIndex ) || 0 ;
749762 var firstRowOffset = ( oldState && oldState . firstRowOffset ) || 0 ;
750763 var scrollX , scrollY ;
751- if ( oldState && props . overflowX !== 'hidden' ) {
752- scrollX = oldState . scrollX ;
753- } else {
764+
765+ scrollX = oldState ? oldState . scrollX : 0 ;
766+ if ( props . scrollLeft !== this . props . scrollLeft ) {
754767 scrollX = props . scrollLeft ;
755768 }
756- if ( oldState && props . overflowY !== 'hidden' ) {
757- scrollY = oldState . scrollY ;
758- } else {
769+
770+ scrollY = oldState ? oldState . scrollY : 0 ;
771+ if ( props . scrollTop !== this . props . scrollTop ) {
759772 scrollState = this . _scrollHelper . scrollTo ( props . scrollTop ) ;
760773 firstRowIndex = scrollState . index ;
761774 firstRowOffset = scrollState . offset ;
@@ -878,7 +891,7 @@ var FixedDataTable = React.createClass({
878891 FixedDataTableWidthHelper . getTotalWidth ( columns ) ;
879892
880893 var horizontalScrollbarVisible = scrollContentWidth > props . width &&
881- props . overflowX !== 'hidden' ;
894+ props . overflowX !== 'hidden' && props . showScrollbarX !== false ;
882895
883896 if ( horizontalScrollbarVisible ) {
884897 bodyHeight -= Scrollbar . SIZE ;
@@ -990,9 +1003,14 @@ var FixedDataTable = React.createClass({
9901003 x += deltaX ;
9911004 x = x < 0 ? 0 : x ;
9921005 x = x > this . state . maxScrollX ? this . state . maxScrollX : x ;
993- this . setState ( {
994- scrollX : x ,
995- } ) ;
1006+
1007+ //NOTE (asif) This is a hacky workaround to prevent FDT from setting its internal state
1008+ var onHorizontalScroll = this . props . onHorizontalScroll ;
1009+ if ( onHorizontalScroll ? onHorizontalScroll ( x ) : true ) {
1010+ this . setState ( {
1011+ scrollX : x ,
1012+ } ) ;
1013+ }
9961014 }
9971015
9981016 this . _didScrollStop ( ) ;
@@ -1005,9 +1023,12 @@ var FixedDataTable = React.createClass({
10051023 if ( ! this . _isScrolling ) {
10061024 this . _didScrollStart ( ) ;
10071025 }
1008- this . setState ( {
1009- scrollX : scrollPos ,
1010- } ) ;
1026+ var onHorizontalScroll = this . props . onHorizontalScroll ;
1027+ if ( onHorizontalScroll ? onHorizontalScroll ( scrollPos ) : true ) {
1028+ this . setState ( {
1029+ scrollX : scrollPos ,
1030+ } ) ;
1031+ }
10111032 this . _didScrollStop ( ) ;
10121033 }
10131034 } ,
0 commit comments