text: import ReactDom from 'react-dom';
  /* mixins for check component visible*/
  const defaultBoundingClientRect = { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  /**
   * Check if `component` is visible in overflow container `parent`
   * @param  {node} component React component
   * @param  {node} parent    component's scroll parent
   * @return {bool}
   */
  function checkOverflowVisible(component, parent) {
    const node = ReactDom.findDOMNode(component);
    let parentTop;
    let parentHeight;
  
    try {
      ({ top: parentTop, height: parentHeight } = parent.getBoundingClientRect());
    } catch (e) {
      ({ top: parentTop, height: parentHeight } = defaultBoundingClientRect);
    }
  
    const windowInnerHeight = window.innerHeight || document.documentElement.clientHeight;
  
    // calculate top and height of the intersection of the element's scrollParent and viewport
    const intersectionTop = Math.max(parentTop, 0); // intersection's top relative to viewport
    const intersectionHeight = Math.min(windowInnerHeight, parentTop + parentHeight) - intersectionTop; // height
  
    // check whether the element is visible in the intersection
    let top;
    let height;
  
    try {
      ({ top, height } = node.getBoundingClientRect());
    } catch (e) {
      ({ top, height } = defaultBoundingClientRect);
    }
  
    const offsetTop = top - intersectionTop; // element's top relative to intersection
  
    const offsets = Array.isArray(component.props.offset) ?
                  component.props.offset :
                  [component.props.offset, component.props.offset]; // Be compatible with previous API
  
    return (offsetTop - offsets[0] <= intersectionHeight) &&
           (offsetTop + height + offsets[1] >= 0);
  };
  
  /**
   * Check if `component` is visible in document
   * @param  {node} component React component
   * @return {bool}
   */
  function checkNormalVisible(component) {
    const node = ReactDom.findDOMNode(component);
    // If this element is hidden by css rules somehow, it's definitely invisible
    if (!(node.offsetWidth || node.offsetHeight || node.getClientRects().length)) return false;
  
    let top;
    let elementHeight;
  
    try {
      ({ top, height: elementHeight } = node.getBoundingClientRect());
    } catch (e) {
      ({ top, height: elementHeight } = defaultBoundingClientRect);
    }
  
    const windowInnerHeight = window.innerHeight || document.documentElement.clientHeight;
  
    const offsets = Array.isArray(component.props.offset) ?
                  component.props.offset :
                  [component.props.offset, component.props.offset]; // Be compatible with previous API
  
    return (top - offsets[0] <= windowInnerHeight) &&
           (top + elementHeight + offsets[1] >= 0);
  };
  
  export {
    checkNormalVisible,
    checkOverflowVisible,
  }