MCPcopy Index your code
hub / github.com/XIU2/UserScript / isElementInViewport

Function isElementInViewport

Zhihu-Enhanced.user.js:432–440  ·  view source on GitHub ↗
(el)

Source from the content-addressed store, hash-verified

430
431//获取元素是否在可视区域(完全可见)
432function isElementInViewport(el) {
433 let rect = el.getBoundingClientRect();
434 return (
435 rect.top >= 0 &&
436 rect.left >= 0 &&
437 rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
438 rect.right <= (window.innerWidth || document.documentElement.clientWidth)
439 );
440}
441//获取元素是否在可视区域(部分可见)
442function isElementInViewport_(el) {
443 let rect = el.getBoundingClientRect();

Callers 1

collapsedNowAnswerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected