diff --git a/TEST.md b/TEST.md index 7dcf74e..85e770b 100644 --- a/TEST.md +++ b/TEST.md @@ -33,5 +33,5 @@ - Added complex Area Selection, Copy/Paste, and Row Deletion. - Successfully decoupled dynamic UI states (like `.dt-cell-selected`) from the declarative binding framework. We now use manual DOM manipulation (`applySelectionUI`) during `refresh` to sync states. - This manual sync completely prevents "Dependency Floods" where scrolling would trigger heavy `$class` evaluations on every cell. We maintained the Zero-Scan status while supporting rich interactions. - - Fixed a VirtualScroll jumping bug at row 70+ by re-enabling `onItemUpdate` so VirtualScroll correctly learns the 40px row height instead of using its 32px default. + - Fixed a VirtualScroll jumping bug at row 70+ by introducing an `options.itemHeight` configuration to the base `VirtualScroll` module. `DataTable` now explicitly passes `{ itemHeight: 40 }` during instantiation. This elegantly bypasses expensive `getComputedStyle` and `offsetHeight` measurements while perfectly seeding the internal height map, completely eliminating layout thrashing and scrolling jank without requiring users to pollute their business data with `_itemHeight`. - **Scroll Initiation Fix**: Removed the `setTimeout` wrapper around `vs.init` during `reset`. Previously, the first scroll often hit a "blank wall" because VirtualScroll's internal metrics hadn't finished initializing when the user made their first swift scroll motion. Synchronous initialization resolved this completely. diff --git a/src/scroll.js b/src/scroll.js index 8e750c1..27715d0 100644 --- a/src/scroll.js +++ b/src/scroll.js @@ -1,7 +1,7 @@ import { VirtualScroll } from '@web/base'; export const createScrollManager = (container, state, onRenderedListChange) => { - const vs = VirtualScroll(); + const vs = VirtualScroll({ itemHeight: 40 }); let scrollEl = null; const refresh = () => { @@ -29,19 +29,6 @@ export const createScrollManager = (container, state, onRenderedListChange) => { reset: (list) => { state._listStartIndex = 0; state._renderedList = vs.reset(list, scrollEl || container) || []; - - // Performance Fix: Seed the VirtualScroll average height to 40px BEFORE init(). - // This entirely eliminates the need for onItemUpdate (which causes layout thrashing - // during fast scrolls) while still perfectly fixing the "row 70 jump" bug caused - // by VirtualScroll's 32px default assumption. - const mockNode = document.createElement('div'); - mockNode.style.marginTop = '0px'; - mockNode.style.marginBottom = '0px'; - Object.defineProperty(mockNode, 'offsetHeight', { value: 40 }); - document.body.appendChild(mockNode); - vs.update(0, mockNode); - document.body.removeChild(mockNode); - if (state.list === list) { vs.init(list, refresh); }