Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/hooks/useStickyOffsets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { StickyOffsets } from '../interface';
/**
* Get sticky column offset width
*/
function useStickyOffsets(colWidths: number[], columCount: number, direction: 'ltr' | 'rtl') {
function useStickyOffsets(colWidths: number[], columnCount: number, direction: 'ltr' | 'rtl') {
const stickyOffsets: StickyOffsets = useMemo(() => {
const leftOffsets: number[] = [];
const rightOffsets: number[] = [];
let left = 0;
let right = 0;

for (let start = 0; start < columCount; start += 1) {
for (let start = 0; start < columnCount; start += 1) {
if (direction === 'rtl') {
// Left offset
rightOffsets[start] = right;
right += colWidths[start] || 0;

// Right offset
const end = columCount - start - 1;
const end = columnCount - start - 1;
leftOffsets[end] = left;
left += colWidths[end] || 0;
} else {
Expand All @@ -27,7 +27,7 @@ function useStickyOffsets(colWidths: number[], columCount: number, direction: 'l
left += colWidths[start] || 0;

// Right offset
const end = columCount - start - 1;
const end = columnCount - start - 1;
rightOffsets[end] = right;
right += colWidths[end] || 0;
}
Expand All @@ -37,7 +37,7 @@ function useStickyOffsets(colWidths: number[], columCount: number, direction: 'l
left: leftOffsets,
right: rightOffsets,
};
}, [colWidths, columCount, direction]);
}, [colWidths, columnCount, direction]);

return stickyOffsets;
}
Expand Down