I am faced with the challenge of developing a complex UI control. The structure consists of a left-side TreeTable component, implemented using a <table>
element, and a right-side SVG component that displays data corresponding to each row of the left TreeTable. While both sides need to function independently as per requirements, they also need to synchronize scrolling behaviors.
The overall layout is structured as follows:
<div>
<div id="leftComponent">
<table>...</table
</div>
<div id="rightComponent">
<svg>...</svg>
</div>
</div>
To optimize performance for large datasets with over 1 million rows, I have implemented a feature where only the rows within the viewport on either side are rendered in the DOM.
However, this approach presents the following challenges:
- When scrolling on the right side, due to absolute positioning of elements, achieving synchronization between the two components poses difficulties. For example, part of a row may be visible at the top of the viewport, then all other rows, followed by another partial row at the bottom. How can I offset the content of the leftComponent table to match the rows displayed on the right side? Absolute positioning on the
<tr>
elements is ineffective. Although rasterized scrolling was considered, it was not deemed viable. Attempting to offset the entire<table>
element using something like
affects the sticky header functionality. Are there alternative solutions?<table style="margin-top:1337px">
- As both components operate relatively independently, having separate vertical scrollbars for each side disrupts the UI experience. Hiding the y-axis scrollbar by setting
overflow-y: hidden
disables scrolling on the left side. One potential solution could involve intercepting WheelEvents to simulate ScrollEvents for the rightComponent. Previous attempts to hide the y-axis scrollbar using CSS properties likescrollbar-width: none;
affected both scrollbars. Keeping the x-axis scrollbar intact visually and functionally while hiding the y-axis scrollbar remains a challenge. Experimenting with techniques such asmargin-right: -20px
successfully hides the y-axis scrollbar but seems cumbersome.
In summary:
- Both components must maintain relative independence while exhibiting synchronized behavior.
- Visual removal of the y-axis scrollbar between components without compromising scrolling ability on the left side is necessary.
- Ability to offset the left
<table>
section based on arbitrary pixel values to align with the freely scrollable right side is essential. - Avoidance of a complete overhaul of the left-side structure by converting the
<table>
into a<div>
structure is preferred due to complexity. - Preservation of performance enhancements for rendering only visible rows while ensuring correct alignment with the right side is crucial.
Seeking innovative solutions for these issues. Your insights and suggestions are appreciated.
EDIT: Added screenshots for clarity. https://i.sstatic.net/mXSO5.png https://i.sstatic.net/3l8nN.png
Description: The first image illustrates perfect alignment when scrolled to the top. Both sets of rows are perfectly matched. In contrast, the second image showcases partially scrolled rows, where the topmost row is barely visible. Aiming to achieve consistent alignment similar to the first image proves challenging due to restrictions of the <table>
structure on the leftComponent. Additionally, eliminating the middle scrollbar, as specified earlier, while retaining horizontal scrolling functionality on both components remains a priority.
For further details, feel free to inquire.