Travis build: 391
This commit is contained in:
@ -13,13 +13,13 @@ const elementIsVisibleInViewport = (el, partiallyVisible = false) => {
|
||||
const { innerHeight, innerWidth } = window;
|
||||
return partiallyVisible
|
||||
? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) &&
|
||||
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
|
||||
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
|
||||
: top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
// e.g. 100x100 viewport and a 10x10px element at position {top: -1, left: 0, bottom: 9, right: 10}
|
||||
elementIsVisibleInViewport(el) // false // (not fully visible)
|
||||
elementIsVisibleInViewport(el, true) // true // (partially visible)
|
||||
elementIsVisibleInViewport(el); // false // (not fully visible)
|
||||
elementIsVisibleInViewport(el, true); // true // (partially visible)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user