22import * as React from "react" ;
33import { isEqual } from "lodash" ;
44
5- import Scroller , { IOnScroll , VERTICAL_SCROLL_DIRECTIONS , HORIZONTAL_SCROLL_DIRECTIONS } from "./scroller" ;
5+ import Scroller , { IOnScroll , VERTICAL_SCROLL_DIRECTIONS , HORIZONTAL_SCROLL_DIRECTIONS , SCROLLBAR_SIZE } from "./scroller" ;
66import {
77 getVisibleIndexesInsideDatalength ,
88 IElevateds ,
@@ -12,6 +12,7 @@ import {
1212 getVirtualizerCache ,
1313 getVisibleItemIndexes ,
1414 getElevatedIndexes ,
15+ getIndexScrollMapping ,
1516} from "./utils/table" ;
1617import { DEFAULT_ROW_HEIGHT , MIN_COLUMN_WIDTH } from "./constants" ;
1718import { Nullable } from "./typing" ;
@@ -252,26 +253,56 @@ class Virtualizer extends React.Component<IVirtualizerProps, IState> {
252253 } = this . props ;
253254 const minCellHeight = minRowHeight || DEFAULT_ROW_HEIGHT ;
254255 const minCellWidth = minColumnWidth || MIN_COLUMN_WIDTH ;
255- this . verticalData = getVirtualizerCache ( {
256- minItemSize : minCellHeight ,
257- fixedItems : fixedRows ,
258- padding : horizontalPadding ,
259- hiddenItems : hiddenRows ,
260- customSizesElements : customCellsHeight ,
261- containerSize : height ,
262- itemsLength : rowsLength ,
263- itemsCount : rowsCount ,
264- } ) ;
265- this . horizontalData = getVirtualizerCache ( {
266- minItemSize : minCellWidth ,
267- fixedItems : fixedColumns ,
268- padding : verticalPadding ,
269- hiddenItems : hiddenColumns ,
270- customSizesElements : customCellsWidth ,
271- containerSize : width ,
272- itemsLength : columnsLength ,
273- itemsCount : columnsCount ,
274- } ) ;
256+ const setverticalData = ( padding : number ) => {
257+ this . verticalData = getVirtualizerCache ( {
258+ minItemSize : minCellHeight ,
259+ fixedItems : fixedRows ,
260+ padding,
261+ hiddenItems : hiddenRows ,
262+ customSizesElements : customCellsHeight ,
263+ containerSize : height ,
264+ itemsLength : rowsLength ,
265+ itemsCount : rowsCount ,
266+ } ) ;
267+ } ;
268+
269+ const sethorizontalData = ( padding : number ) => {
270+ this . horizontalData = getVirtualizerCache ( {
271+ minItemSize : minCellWidth ,
272+ fixedItems : fixedColumns ,
273+ padding,
274+ hiddenItems : hiddenColumns ,
275+ customSizesElements : customCellsWidth ,
276+ containerSize : width ,
277+ itemsLength : columnsLength ,
278+ itemsCount : columnsCount ,
279+ } ) ;
280+ } ;
281+
282+ setverticalData ( horizontalPadding ) ;
283+
284+ const horizontalScrollBarSize =
285+ this . verticalData . virtualSize > ( this . verticalData . scrollableItemsSize || 0 ) ? SCROLLBAR_SIZE : 0 ;
286+ sethorizontalData ( verticalPadding + horizontalScrollBarSize ) ;
287+
288+ const verticalScrollBarSize =
289+ this . horizontalData . virtualSize > ( this . horizontalData . scrollableItemsSize || 0 ) ? SCROLLBAR_SIZE : 0 ;
290+ setverticalData ( verticalScrollBarSize + horizontalPadding ) ;
291+
292+ // Returns the distance (in pixels) between the different items
293+ this . verticalData . itemIndexesScrollMapping = getIndexScrollMapping (
294+ rowsLength ,
295+ customCellsHeight . customSizes ,
296+ this . verticalData . itemSize ,
297+ [ ...this . verticalData . visibleFixedItems , ...hiddenRows ]
298+ ) ;
299+ // Returns the distance (in pixels) between the different items
300+ this . horizontalData . itemIndexesScrollMapping = getIndexScrollMapping (
301+ columnsLength ,
302+ customCellsWidth . customSizes ,
303+ this . horizontalData . itemSize ,
304+ [ ...this . horizontalData . visibleFixedItems , ...hiddenColumns ]
305+ ) ;
275306 } ;
276307
277308 private getVisibleRowIndexes = ( scrollValue = 0 ) => {
0 commit comments