Skip to content

Commit d7d1380

Browse files
committed
Update utils.js
1 parent 8ceb889 commit d7d1380

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

utils.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,21 @@ let moveElToMouse = (originEl, mouseEvent, boundryMargin = null, boundryEl = nul
584584
}
585585

586586

587+
// check if element is in view
588+
let elInView = (el) => {
589+
590+
const rect = el.getBoundingClientRect();
591+
const elemTop = rect.top;
592+
const elemLeft = rect.left;
593+
594+
const isVisible = (elemTop < window.innerHeight &&
595+
elemLeft < window.innerWidth);
596+
597+
return isVisible;
598+
599+
}
600+
601+
587602
// attributes
588603

589604
let getAttr = (element, item) => {

0 commit comments

Comments
 (0)