packages/flyout/src/getCoordinates.js
function createViewportDeterminer(props) {
  const { viewportRect, panelRect, actionRect } = props;

  return function isInViewport({ containerPosition }) {
    const containerTop = actionRect.top + containerPosition.top;
    const containerLeft = actionRect.left + containerPosition.left;
    const containerRight = containerLeft + panelRect.width;
    const containerBottom = containerTop + panelRect.height;
    const result =
      containerLeft >= viewportRect.left &&
      containerTop >= viewportRect.top &&
      containerRight <= viewportRect.right &&
      containerBottom <= viewportRect.bottom;

    return result;
  };
}
function createViewportDeterminer(props) {
  const { viewportRect, panelRect, actionRect } = props;

  return function isInViewport({ containerPosition }) {
    const containerTop = actionRect.top + containerPosition.top;
    const containerLeft = actionRect.left + containerPosition.left;
    const containerRight = containerLeft + panelRect.width;
    const containerBottom = containerTop + panelRect.height;
    const result =
      containerLeft >= viewportRect.left &&
      containerTop >= viewportRect.top &&
      containerRight <= viewportRect.right &&
      containerBottom <= viewportRect.bottom;

    return result;
  };
}
function createViewportDeterminer ( props ) { const { viewportRect , panelRect , actionRect } = props ; return function isInViewport ( { containerPosition } ) { const containerTop = actionRect . top + containerPosition . top ; const containerLeft = actionRect . left + containerPosition . left ; const containerRight = containerLeft + panelRect . width ; const containerBottom = containerTop + panelRect . height ; const result = containerLeft >= viewportRect . left && containerTop >= viewportRect . top && containerRight <= viewportRect . right && containerBottom <= viewportRect . bottom ; return result ; } ; }
Determines whether the given position is entirely within the viewport
@param {Payload} payload
@returns {function(Coordinates): boolean}
Determines whether the given position is entirely within the viewport