superdesk/superdesk-client-core

View on GitHub
scripts/core/helpers/dom/isElementInViewport.ts

Summary

Maintainability
A
0 mins
Test Coverage
export function isElementInViewport(element) {
    var rect = element.getBoundingClientRect();

    return rect.top >= 0
        && rect.left >= 0
        && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)
        && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
}