Skip to content

Commit af5388a

Browse files
committed
add horizontal scrollTo
1 parent 2145f32 commit af5388a

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

packages/main/src/components/AnalyticalTable/ColumnHeader/ColumnHeaderContainer.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export const ColumnHeaderContainer = (props) => {
3939
tableRef,
4040
visibleColumnsWidth,
4141
overscanCountHorizontal,
42-
resizeInfo
42+
resizeInfo,
43+
reactWindowRef
4344
} = props;
4445
const columnVirtualizer = useVirtual({
4546
size: visibleColumnsWidth.length,
@@ -54,6 +55,12 @@ export const ColumnHeaderContainer = (props) => {
5455
overscan: overscanCountHorizontal
5556
});
5657

58+
reactWindowRef.current = {
59+
...reactWindowRef.current,
60+
horizontalScrollToOffset: columnVirtualizer.scrollToOffset,
61+
horizontalScrollToIndex: columnVirtualizer.scrollToIndex
62+
};
63+
5764
const classes = useStyles();
5865

5966
return (

packages/main/src/components/AnalyticalTable/TableBody/VirtualTableBody.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const VirtualTableBody = (props: VirtualTableBodyProps) => {
6565
});
6666

6767
reactWindowRef.current = {
68+
...reactWindowRef.current,
6869
scrollToOffset: rowVirtualizer.scrollToOffset,
6970
scrollToIndex: rowVirtualizer.scrollToIndex
7071
};

packages/main/src/components/AnalyticalTable/hooks/useTableScrollHandles.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,26 @@ export const useTableScrollHandles = (ref) => {
1818
if (typeof reactWindowRef.current?.scrollToIndex === 'function') {
1919
reactWindowRef.current.scrollToIndex(index, { align });
2020
}
21+
},
22+
horizontalScrollTo: (offset, align) => {
23+
if (typeof reactWindowRef.current?.horizontalScrollToOffset === 'function') {
24+
reactWindowRef.current.horizontalScrollToOffset(offset, { align });
25+
}
26+
},
27+
horizontalScrollToItem: (index, align) => {
28+
if (typeof reactWindowRef.current?.horizontalScrollToIndex === 'function') {
29+
reactWindowRef.current.horizontalScrollToIndex(index, { align });
30+
}
2131
}
2232
});
2333
}
24-
}, [analyticalTableRef.current, reactWindowRef.current.scrollToIndex, reactWindowRef.current.scrollToOffset]);
34+
}, [
35+
analyticalTableRef.current,
36+
reactWindowRef.current.scrollToIndex,
37+
reactWindowRef.current.scrollToOffset,
38+
reactWindowRef.current.horizontalScrollToIndex,
39+
reactWindowRef.current.horizontalScrollToOffset
40+
]);
2541

2642
return [analyticalTableRef, reactWindowRef];
2743
};

packages/main/src/components/AnalyticalTable/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
415415
return (
416416
tableRef.current && (
417417
<ColumnHeaderContainer
418+
reactWindowRef={reactWindowRef}
418419
tableRef={tableRef}
419420
resizeInfo={tableState.columnResizing}
420421
visibleColumnsWidth={visibleColumnsWidth}

0 commit comments

Comments
 (0)