feat: Enhance scrolling behavior and styles across components; add centralized scroll utilities

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-28 22:51:50 +10:00
parent e6af56a417
commit cad4852878
8 changed files with 151 additions and 61 deletions

View File

@@ -5,6 +5,7 @@ import {
getScrollInfo,
isInScrollView,
isIntersectingScrollView,
scrollToPosition,
} from '../utils/dom';
const PAGINATOR_ANCHOR_ATTR = 'data-paginator-anchor';
@@ -218,7 +219,7 @@ export const useVirtualPaginator = <TScrollElement extends HTMLElement>(
scrollTo = element.offsetTop - Math.round(scrollInfo.viewHeight) + element.clientHeight;
}
scrollElement.scrollTo({
scrollToPosition(scrollElement, {
top: scrollTo - (opts?.offset ?? 0),
behavior: opts?.behavior,
});
@@ -253,10 +254,12 @@ export const useVirtualPaginator = <TScrollElement extends HTMLElement>(
if (!itemElement) {
const scrollElement = getScrollElement();
scrollElement?.scrollTo({
top: opts?.offset ?? 0,
behavior: opts?.behavior,
});
if (scrollElement) {
scrollToPosition(scrollElement, {
top: opts?.offset ?? 0,
behavior: opts?.behavior,
});
}
return true;
}
return scrollToElement(itemElement, opts);
@@ -364,7 +367,7 @@ export const useVirtualPaginator = <TScrollElement extends HTMLElement>(
const offsetAddition = offsetTop - oldOffsetTop;
const restoreTop = oldScrollTop + offsetAddition;
scrollEl.scrollTo({
scrollToPosition(scrollEl, {
top: restoreTop,
behavior: 'instant',
});