UNPKG

react-lazily-render-scroll-parent

Version:
28 lines (26 loc) 907 B
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; import '../types'; import getElementBounds from './getElementBounds'; export default function (container) { if (!container) { return undefined; } if (container === window) { return { top: window.pageYOffset, left: window.pageXOffset, bottom: window.pageYOffset + window.innerHeight, right: window.pageXOffset + window.innerWidth }; } else { var bounds = getElementBounds(container); if (bounds) { return _extends({}, bounds, { bottom: bounds.top + container.offsetHeight, right: bounds.left + container.offsetWidth }); } else { return undefined; } } }