@zohodesk/components
Version:
Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development
13 lines • 779 B
JavaScript
export const scrollTo = function (suggestionContainer, selSuggestion) {
if (selSuggestion && suggestionContainer) {
if (suggestionContainer.scrollHeight === selSuggestion.offsetTop + selSuggestion.offsetHeight) {
suggestionContainer.scrollTop = selSuggestion.offsetTop - selSuggestion.offsetHeight;
} else if (selSuggestion.offsetTop === 0) {
suggestionContainer.scrollTop = 0;
} else if (suggestionContainer.offsetHeight + suggestionContainer.scrollTop < selSuggestion.offsetTop) {
suggestionContainer.scrollTop = selSuggestion.offsetTop - selSuggestion.offsetHeight;
} else if (suggestionContainer.scrollTop > selSuggestion.offsetTop) {
suggestionContainer.scrollTop = selSuggestion.offsetTop - selSuggestion.offsetHeight;
}
}
};