UNPKG

@skbkontur/db-viewer-ui

Version:

Database Viewer with custom configuration

23 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateScrollbarPosition = exports.isScrollbarInViewport = void 0; const top = (element) => element.getBoundingClientRect().top; const bottom = (element) => element.getBoundingClientRect().bottom; const isScrollbarInViewport = (containerElement, scrollbarElement) => { const containerTop = top(containerElement); const containerBottom = bottom(containerElement); const scrollbarTop = top(scrollbarElement); const scrollbarBottom = bottom(scrollbarElement); return containerTop < scrollbarTop && containerBottom > scrollbarBottom; }; exports.isScrollbarInViewport = isScrollbarInViewport; const updateScrollbarPosition = (containerElement, scrollbarElement, scrollbarChildElement, currentScrollLeft) => { const containerRect = containerElement.getBoundingClientRect(); const containerWidth = Math.ceil(containerRect.right - containerRect.left); scrollbarChildElement.style.width = `${containerElement.scrollWidth}px`; scrollbarElement.style.left = `${containerRect.left}px`; scrollbarElement.style.width = `${containerWidth}px`; scrollbarElement.scrollLeft = currentScrollLeft; }; exports.updateScrollbarPosition = updateScrollbarPosition; //# sourceMappingURL=helpers.js.map