UNPKG

e2ed

Version:

E2E testing framework over Playwright

15 lines (14 loc) 723 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isSelectorEntirelyInViewport = void 0; /** * Returns `true`, if the selector is entirely in the viewport * (all selector points are in the viewport), and `false` otherwise. */ const isSelectorEntirelyInViewport = 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 >= 0 && bottom <= clientHeight && left >= 0 && right <= clientWidth; }; exports.isSelectorEntirelyInViewport = isSelectorEntirelyInViewport;