File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -462,6 +462,10 @@ export function sigmoid(x) {
462
462
/**
463
463
* Return whether an element is practically visible, considering things like 0
464
464
* size or opacity, ``visibility: hidden`` and ``overflow: hidden``.
465
+ *
466
+ * Merely being scrolled off the page in either horizontally or vertically
467
+ * doesn't count as invisible; the result of this function is meant to be
468
+ * independent of viewport size.
465
469
*/
466
470
export function isVisible ( fnodeOrElement ) {
467
471
// This could be 5x more efficient if https://github.com/w3c/csswg-drafts/issues/4122 happens.
@@ -475,11 +479,9 @@ export function isVisible(fnodeOrElement) {
475
479
if ( elementStyle . visibility === 'hidden' ) {
476
480
return false ;
477
481
}
478
- // Check if the element is off-screen:
479
- const frame = element . ownerDocument . defaultView ;
482
+ // Check if the element is irrevocably off-screen:
480
483
if ( elementRect . x + elementRect . width < 0 ||
481
- elementRect . y + elementRect . height < 0 ||
482
- elementRect . x > frame . innerWidth || elementRect . y > frame . innerHeight
484
+ elementRect . y + elementRect . height < 0
483
485
) {
484
486
return false ;
485
487
}
You can’t perform that action at this time.
0 commit comments