From 6e7f0030af74e5ee35e99136e40bef7b1047e04b Mon Sep 17 00:00:00 2001 From: gokulk94 Date: Fri, 22 Dec 2017 14:40:18 +0530 Subject: [PATCH] add missing line of code to elementIsVisibleInViewport --- README.md | 2 +- snippets/elementIsVisibleInViewport.md | 1 + snippets/orderBy.md | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 25490e54e..6bf32bb07 100644 --- a/README.md +++ b/README.md @@ -878,6 +878,7 @@ it is partially visible. ```js const elementIsVisibleInViewport = (el, partiallyVisible = false) => { const { top, left, bottom, right } = el.getBoundingClientRect(); + const { innerHeight, innerWidth } = window; return partiallyVisible ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) && ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth)) @@ -1694,7 +1695,6 @@ orderby(users, ['name', 'age']) -> [{name: 'barney', age: 34}, {name: 'barney', */ ``` - [⬆ back to top](#table-of-contents) ### select diff --git a/snippets/elementIsVisibleInViewport.md b/snippets/elementIsVisibleInViewport.md index 4f52d6ad7..01015d4fc 100644 --- a/snippets/elementIsVisibleInViewport.md +++ b/snippets/elementIsVisibleInViewport.md @@ -10,6 +10,7 @@ it is partially visible. ```js const elementIsVisibleInViewport = (el, partiallyVisible = false) => { const { top, left, bottom, right } = el.getBoundingClientRect(); + const { innerHeight, innerWidth } = window; return partiallyVisible ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) && ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth)) diff --git a/snippets/orderBy.md b/snippets/orderBy.md index 21baef3ac..c80b3667f 100644 --- a/snippets/orderBy.md +++ b/snippets/orderBy.md @@ -23,4 +23,3 @@ orderby(users, ['name', 'age'], ['asc', 'desc']) -> [{name: 'barney', age: 36}, orderby(users, ['name', 'age']) -> [{name: 'barney', age: 34}, {name: 'barney', age: 36}, {name: 'fred', age: 40}, {name: 'fred', age: 48}] */ ``` -