adjust styling
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user