UNPKG

@awsui/components-react

Version:

AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A

13 lines (12 loc) 528 B
export function scrollIntoViewWithOffset(element, _a) { var top = _a.top, bottom = _a.bottom; var rect = element.getBoundingClientRect(); var distanceToUpperWindowEdge = rect.top; var distanceToLowerWindowEdge = window.innerHeight - (distanceToUpperWindowEdge + rect.height); if (distanceToLowerWindowEdge < bottom) { window.scrollBy(0, bottom - distanceToLowerWindowEdge); } else if (distanceToUpperWindowEdge < top) { window.scrollBy(0, -(top - distanceToUpperWindowEdge)); } }