@@ -31,7 +31,6 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
3131 childrenColumnName,
3232 emptyNode,
3333 scrollX,
34- componentWidth,
3534 } = useContext ( TableContext , [
3635 'flattenColumns' ,
3736 'onColumnResize' ,
@@ -41,13 +40,11 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
4140 'childrenColumnName' ,
4241 'emptyNode' ,
4342 'scrollX' ,
44- 'componentWidth' ,
4543 ] ) ;
4644 const {
4745 sticky,
4846 scrollY,
4947 listItemHeight,
50- horizontalVirtual,
5148 getComponent,
5249 onScroll : onTablePropScroll ,
5350 } = useContext ( StaticContext ) ;
@@ -72,8 +69,6 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
7269 [ columnsWidth ] ,
7370 ) ;
7471
75- const [ scrollLeft , setScrollLeft ] = React . useState ( 0 ) ;
76-
7772 React . useEffect ( ( ) => {
7873 columnsWidth . forEach ( ( [ key , width ] ) => {
7974 onColumnResize ( key , width ) ;
@@ -92,12 +87,6 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
9287 get : ( ) => listRef . current ?. getScrollInfo ( ) . x || 0 ,
9388
9489 set : ( value : number ) => {
95- if ( horizontalVirtual ) {
96- const max = ( scrollX as number ) - componentWidth ;
97- let left = Math . max ( value , 0 ) ;
98- left = Math . min ( left , max ) ;
99- setScrollLeft ( left ) ;
100- }
10190 listRef . current ?. scrollTo ( {
10291 left : value ,
10392 } ) ;
@@ -120,7 +109,7 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
120109 } ;
121110
122111 const extraRender : ListProps < any > [ 'extraRender' ] = info => {
123- const { start, end, getSize, offsetY } = info ;
112+ const { start, end, getSize, offsetX , offsetY } = info ;
124113
125114 // Do nothing if no data
126115 if ( end < 0 ) {
@@ -200,9 +189,9 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
200189 style = { {
201190 top : - offsetY + sizeInfo . top ,
202191 } }
192+ offsetX = { offsetX }
203193 extra
204194 getHeight = { getHeight }
205- scrollLeft = { scrollLeft }
206195 />
207196 ) ;
208197 } ) ;
@@ -247,9 +236,6 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
247236 component = { wrapperComponent }
248237 scrollWidth = { scrollX as number }
249238 onVirtualScroll = { ( { x } ) => {
250- if ( horizontalVirtual ) {
251- setScrollLeft ( x ) ;
252- }
253239 onScroll ( {
254240 scrollLeft : x ,
255241 } ) ;
@@ -259,15 +245,7 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
259245 >
260246 { ( item , index , itemProps ) => {
261247 const rowKey = getRowKey ( item . record , index ) ;
262- return (
263- < BodyLine
264- data = { item }
265- rowKey = { rowKey }
266- index = { index }
267- scrollLeft = { scrollLeft }
268- { ...itemProps }
269- />
270- ) ;
248+ return < BodyLine data = { item } rowKey = { rowKey } index = { index } { ...itemProps } /> ;
271249 } }
272250 </ VirtualList >
273251 ) ;
0 commit comments