3 ms·
If a user is trying to scroll horizontally, we can get the delta and get the scroll direction. Find the column width of the next/prev column and update the scro
by rowsncolumns 6y ago
If a user is trying to scroll horizontally, we can get the delta and get the scroll direction. Find the column width of the next/prev column and update the scroll property. An implementation can look like:
const nextColumnIndex =
scrollDeltaX < 0
? Math.max(0, columnStart - 1)
: Math.min(columnStart, columnCount - 1);
const columnWidth = getColumnWidth(
nextColumnIndex
);
scrollBar.scrollLeft += (scrollDeltaX < 0 ? -1 : 1) * columnWidth;