adjust styling

This commit is contained in:
Elijah Duffy
2025-07-04 03:17:43 -07:00
parent e6e58ab106
commit 104d99661c
4 changed files with 21 additions and 13 deletions

View File

@@ -169,13 +169,17 @@
const highlightedElement = pickerContainer.querySelector(`[data-id="${highlighted.value}"]`);
if (!highlightedElement) return;
const rect = highlightedElement.getBoundingClientRect();
const pickerRect = pickerContainer.getBoundingClientRect();
const containerTop = pickerContainer.scrollTop;
const containerHeight = pickerContainer.clientHeight;
const elementOffsetTop = (highlightedElement as HTMLElement).offsetTop;
const elementHeight = (highlightedElement as HTMLElement).offsetHeight;
if (rect.top - 20 < pickerRect.top) {
pickerContainer.scrollTop -= pickerRect.top - rect.top + 20;
} else if (rect.bottom + 20 > pickerRect.bottom) {
pickerContainer.scrollTop += rect.bottom - pickerRect.bottom + 20;
const offset = 8; // px, adjust as needed
if (elementOffsetTop < containerTop + offset) {
pickerContainer.scrollTop = Math.max(elementOffsetTop - offset, 0);
} else if (elementOffsetTop + elementHeight > containerTop + containerHeight - offset) {
pickerContainer.scrollTop = elementOffsetTop + elementHeight - containerHeight + offset;
}
};