File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,15 @@ export interface VirtualCellProps<RecordType> {
3131 * Return the width of the column by `colSpan`.
3232 * When `colSpan` is `0` will be trade as `1`.
3333 */
34- export function getColumnWidth ( colIndex : number , colSpan : number , columnsOffset : number [ ] ) {
34+ export function getColumnWidth ( colIndex : number , colSpan : number , columnsOffset : number [ ] ) : number {
3535 const mergedColSpan = colSpan || 1 ;
36- return columnsOffset [ colIndex + mergedColSpan ] - ( columnsOffset [ colIndex ] || 0 ) ;
36+
37+ const startIndex = Math . max ( colIndex , 0 ) ;
38+ const endIndex = Math . min ( startIndex + mergedColSpan , columnsOffset . length - 1 ) ;
39+
40+ const startOffset = columnsOffset [ startIndex ] || 0 ;
41+ const endOffset = columnsOffset [ endIndex ] || startOffset ;
42+ return Math . max ( endOffset - startOffset , 0 ) ;
3743}
3844
3945const VirtualCell = < RecordType , > ( props : VirtualCellProps < RecordType > ) => {
You can’t perform that action at this time.
0 commit comments