const isHidden = (element) =>
  element.offsetParent === null;

const offset = (element) => {
  const rect = element.getBoundingClientRect();

  return {
    top: rect.top + window.pageYOffset,
    left: rect.left + window.pageXOffset,
  };
};

const inViewport = (element, container, customOffset) => {
  if (isHidden(element)) {
    return false;
  }

  let top, left, bottom, right;

  if (typeof container === 'undefined' || container === window) {
    top = window.pageYOffset;
    left = window.pageXOffset;
    bottom = top + window.innerHeight;
    right = left + window.innerWidth;
  } else {
    const containerOffset = offset(container);

    top = containerOffset.top;
    left = containerOffset.left;
    bottom = top + container.offsetHeight;
    right = left + container.offsetWidth;
  }

  const elementOffset = offset(element);

  return (
    top < elementOffset.top + customOffset.bottom + element.offsetHeight &&
    bottom > elementOffset.top - customOffset.top &&
    left < elementOffset.left + customOffset.right + element.offsetWidth &&
    right > elementOffset.left - customOffset.left
  );
};

module.exports = inViewport;
@@ -614,22 +614,24 @@
 ontainer
-Offset
+Position
  = offse
@@ -664,22 +664,24 @@
 ontainer
-Offset
+Position
 .top;%0A  
@@ -698,22 +698,24 @@
 ontainer
-Offset
+Position
 .left;%0A 
@@ -818,22 +818,24 @@
  element
-Offset
+Position
  = offse
@@ -867,24 +867,25 @@
    top %3C
+=
  element
 Offset.t
@@ -880,40 +880,20 @@
 ment
-Offset.top + customOffset.bottom
+Position.top
  + e
@@ -912,16 +912,35 @@
 tHeight 
++ customOffset.top 
 &&%0A    b
@@ -946,24 +946,25 @@
 bottom %3E
+=
  element
 Offset.t
@@ -955,22 +955,24 @@
  element
-Offset
+Position
 .top - c
@@ -975,35 +975,38 @@
  - customOffset.
+bot
 to
-p
+m
  &&%0A    left %3C e
@@ -1003,24 +1003,25 @@
   left %3C
+=
  element
 Offset.l
@@ -1016,62 +1016,63 @@
 ment
-Offset.left + customOffset.right + element.offsetWidth
+Position.left + element.offsetWidth + customOffset.left
  &&%0A
@@ -1082,24 +1082,25 @@
  right %3E
+=
  element
 Offset.l
@@ -1091,22 +1091,24 @@
  element
-Offset
+Position
 .left - 
@@ -1120,19 +1120,20 @@
 mOffset.
-lef
+righ
 t%0A  );%0A%7D
@@ -1163,8 +1163,9 @@
 iewport;
+%0A

fix inViewport