Skip to content

Commit 0bd03b3

Browse files
committed
Merge remote-tracking branch 'origin/master' into devtools
2 parents 4d5703f + d8bfb6e commit 0bd03b3

File tree

11 files changed

+3710
-34
lines changed

11 files changed

+3710
-34
lines changed

examples/src/pages/tests/table/perf/default-horizontal-scrolling-2025-04-08_20:27:54.trace.json

Lines changed: 3649 additions & 0 deletions
Large diffs are not rendered by default.

source/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"bugs": {
2626
"url": "https://github.com/infinite-table/infinite-react/issues"
2727
},
28-
"version": "6.2.10",
28+
"version": "6.2.11",
2929
"main": "index.js",
3030
"module": "index.mjs",
3131
"typings": "index.d.ts",

source/src/components/HeadlessTable/index.tsx

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ import { ActiveCellIndicator } from '../InfiniteTable/components/ActiveCellIndic
2828
import { join } from '../../utils/join';
2929
import { TableRenderCellFn, TableRenderDetailRowFn } from './rendererTypes';
3030
import { GridRenderer } from './ReactHeadlessTableRenderer';
31-
import { InternalVars } from '../InfiniteTable/internalVars.css';
32-
import { stripVar } from '../../utils/stripVar';
31+
// import { InternalVars } from '../InfiniteTable/internalVars.css';
32+
// import { stripVar } from '../../utils/stripVar';
3333
import { CELL_DETACHED_CLASSNAMES } from '../InfiniteTable/components/cellDetachedCls';
3434

35-
const virtualScrollLeftOffset = stripVar(InternalVars.virtualScrollLeftOffset);
36-
const virtualScrollTopOffset = stripVar(InternalVars.virtualScrollTopOffset);
35+
// const virtualScrollLeftOffset = stripVar(InternalVars.virtualScrollLeftOffset);
36+
// const virtualScrollTopOffset = stripVar(InternalVars.virtualScrollTopOffset);
3737

3838
export type HeadlessTableProps = {
3939
scrollerDOMRef?: MutableRefObject<HTMLElement | null>;
@@ -215,30 +215,33 @@ export function HeadlessTable(
215215

216216
const updateDOMTransform = useCallback((scrollPos: ScrollPosition) => {
217217
requestAnimationFrame(() => {
218-
const scrollVarHost = scrollVarHostRef?.current;
219-
220-
if (!scrollVarHost) {
221-
if (!domRef.current) {
222-
// we're in a raf, so the component might have been unmounted in the meantime
223-
// so we protect against that
224-
return;
225-
}
226-
domRef.current!.style.setProperty(
227-
'transform',
228-
`translate3d(${-scrollPos.scrollLeft}px, ${-scrollPos.scrollTop}px, 0px)`,
229-
);
218+
// const scrollVarHost = scrollVarHostRef?.current;
219+
220+
// if (!scrollVarHost) {
221+
// seems like it's a lot less performant to scroll via CSS vars
222+
// as STYLE RECALCULATION is a lot more expensive than using the transform property
223+
224+
if (!domRef.current) {
225+
// we're in a raf, so the component might have been unmounted in the meantime
226+
// so we protect against that
230227
return;
231228
}
232-
233-
scrollVarHost.style.setProperty(
234-
virtualScrollLeftOffset,
235-
`-${scrollPos.scrollLeft}px`,
229+
domRef.current!.style.setProperty(
230+
'transform',
231+
`translate3d(${-scrollPos.scrollLeft}px, ${-scrollPos.scrollTop}px, 0px)`,
236232
);
233+
return;
234+
// }
237235

238-
scrollVarHost.style.setProperty(
239-
virtualScrollTopOffset,
240-
`-${scrollPos.scrollTop}px`,
241-
);
236+
// scrollVarHost.style.setProperty(
237+
// virtualScrollLeftOffset,
238+
// `-${scrollPos.scrollLeft}px`,
239+
// );
240+
241+
// scrollVarHost.style.setProperty(
242+
// virtualScrollTopOffset,
243+
// `-${scrollPos.scrollTop}px`,
244+
// );
242245
});
243246
}, []);
244247

source/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { useCallback, useRef } from 'react';
2+
import { useCallback, useEffect, useRef } from 'react';
33

44
import { join } from '../../../../utils/join';
55
import { RawTable } from '../../../HeadlessTable/RawTable';
@@ -18,6 +18,7 @@ import { HeaderClsRecipe } from './header.css';
1818
import { InfiniteTableHeaderCell } from './InfiniteTableHeaderCell';
1919
import { InfiniteTableHeaderGroup } from './InfiniteTableHeaderGroup';
2020
import type { InfiniteTableHeaderProps } from './InfiniteTableHeaderTypes';
21+
import type { ScrollPosition } from '../../../types/ScrollPosition';
2122

2223
const { rootClassName } = internalProps;
2324

@@ -52,6 +53,22 @@ function InfiniteTableHeaderFn<T>(
5253
const { computedColumnsMap } = computed;
5354

5455
const domRef = useRef<HTMLDivElement | null>(null);
56+
const updateDOMTransform = useCallback((scrollPosition: ScrollPosition) => {
57+
if (domRef.current) {
58+
domRef.current.style.transform = `translate3d(-${scrollPosition.scrollLeft}px, 0px, 0px)`;
59+
}
60+
}, []);
61+
62+
useEffect(() => {
63+
const removeOnScroll = headerBrain.onScroll(updateDOMTransform);
64+
65+
// useful when the brain is changed - when toggling the value of wrapRowsHorizontally
66+
updateDOMTransform(
67+
headerBrain.getScrollPosition() || { scrollLeft: 0, scrollTop: 0 },
68+
);
69+
70+
return removeOnScroll;
71+
}, [headerBrain]);
5572

5673
const domProps: React.HTMLProps<HTMLDivElement> = {
5774
ref: domRef,

source/src/components/InfiniteTable/components/InfiniteTableHeader/header.css.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
CellClsVariants,
2323
ColumnCellVariantsObject,
2424
} from '../cell.css';
25-
import { InternalVars } from '../../internalVars.css';
2625

2726
export { CellCls, CellClsVariants };
2827

@@ -84,7 +83,8 @@ export const HeaderClsRecipe = recipe({
8483
{
8584
background: ThemeVars.components.Header.background,
8685
color: ThemeVars.components.Header.color,
87-
transform: `translate3d(${InternalVars.virtualScrollLeftOffset}, 0px, 0px)`,
86+
// transform: `translate3d(${InternalVars.virtualScrollLeftOffset}, 0px, 0px)`,
87+
transform: `translate3d(0px, 0px, 0px)`,
8888
},
8989
],
9090

source/src/components/InfiniteTable/internalVars.css.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ export const InternalVars = createThemeContract({
4545
scrollLeft: null,
4646
scrollTop: null,
4747

48-
virtualScrollLeftOffset: null,
49-
virtualScrollTopOffset: null,
48+
// virtualScrollLeftOffset: null,
49+
// virtualScrollTopOffset: null,
5050
});

source/src/components/VirtualScrollContainer/VirtualScrollContainer.css.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { style } from '@vanilla-extract/css';
2-
import { InternalVars } from '../InfiniteTable/internalVars.css';
32
import { boxSizingBorderBox } from '../InfiniteTable/utilities.css';
43

54
export const VirtualScrollContainerCls = style([
@@ -30,7 +29,8 @@ export const VirtualScrollContainerCls = style([
3029
export const VirtualScrollContainerChildToScrollCls = style({
3130
position: 'sticky',
3231
willChange: 'transform',
33-
transform: `translate3d(${InternalVars.virtualScrollLeftOffset}, ${InternalVars.virtualScrollTopOffset}, 0px)`,
32+
// transform: `translate3d(${InternalVars.virtualScrollLeftOffset}, ${InternalVars.virtualScrollTopOffset}, 0px)`,
33+
transform: `translate3d(0px, 0px, 0px)`,
3434
contain: 'size layout', // TODO THIS MIGHT MISBEHAVE!!! CAN REMOVE IF IT INTRODUCES BROWSER REPAINT/RELAYOUT BUGS
3535
top: 0,
3636
left: 0,

www/content/docs/releases/index.page.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ title: Releases
33
description: All releases | Infinite Table DataGrid for React
44
---
55

6+
## 6.2.11
7+
8+
Improve performance on heavy scrolling by avoiding CSS vars for scroll pos.
9+
610
## 6.2.10
711

812
Recompute DataSource repeat wrapped group rows when `wrapRowsHorizontally` changes.

www/src/components/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22
import cn from 'classnames';
3-
import { ReactNode } from '@mdx-js/react/lib';
3+
import { ReactNode } from 'react';
44
import Link from 'next/link';
55

66
import * as React from 'react';

0 commit comments

Comments
 (0)