e2ed
Version:
E2E testing framework over Playwright
15 lines (14 loc) • 689 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSelectorInViewport = void 0;
/**
* Returns `true`, if the selector is in the viewport
* (intersects with the viewport at least in one point), and `false` otherwise.
*/
const isSelectorInViewport = async (selector) => {
const htmlElementSelector = selector.createSelector('html');
const { height: clientHeight, width: clientWidth } = await htmlElementSelector.boundingClientRect;
const { bottom, left, right, top } = await selector.boundingClientRect;
return top < clientHeight && bottom > 0 && left < clientWidth && right > 0;
};
exports.isSelectorInViewport = isSelectorInViewport;