src/PopupSource.js
function measurePopup(element) {

  const windowHeight = window.innerHeight;
  const windowWidth = window.innerWidth;

  const popupRect = element.$.popup.getBoundingClientRect();
  const popupHeight = popupRect.height;
  const popupWidth = popupRect.width;
  
  const sourceRect = element.getBoundingClientRect();
  const roomAbove = sourceRect.top;
  const roomBelow = Math.ceil(windowHeight - sourceRect.bottom);
  const roomLeft = sourceRect.right;
  const roomRight = Math.ceil(windowWidth - sourceRect.left);

  const popupMeasured = true;
  
  element.setState({
    popupHeight,
    popupMeasured,
    popupWidth,
    roomAbove,
    roomBelow,
    roomLeft,
    roomRight,
    windowHeight,
    windowWidth
  });
}
function measurePopup(element) {

  const windowHeight = window.innerHeight;
  const windowWidth = window.innerWidth;

  const popupRect = element.$.popup.getBoundingClientRect();
  const popupHeight = popupRect.height;
  const popupWidth = popupRect.width;
  
  const sourceRect = element.getBoundingClientRect();
  const roomAbove = sourceRect.top;
  const roomBelow = Math.ceil(windowHeight - sourceRect.bottom);
  const roomLeft = sourceRect.right;
  const roomRight = Math.ceil(windowWidth - sourceRect.left);

  const popupMeasured = true;
  
  element.setState({
    popupHeight,
    popupMeasured,
    popupWidth,
    roomAbove,
    roomBelow,
    roomLeft,
    roomRight,
    windowHeight,
    windowWidth
  });
}
function measurePopup ( element ) { const windowHeight = window . innerHeight ; const windowWidth = window . innerWidth ; const popupRect = element . $ . popup . getBoundingClientRect ( ) ; const popupHeight = popupRect . height ; const popupWidth = popupRect . width ; const sourceRect = element . getBoundingClientRect ( ) ; const roomAbove = sourceRect . top ; const roomBelow = Math . ceil ( windowHeight - sourceRect . bottom ) ; const roomLeft = sourceRect . right ; const roomRight = Math . ceil ( windowWidth - sourceRect . left ) ; const popupMeasured = true ; element . setState ( { popupHeight , popupMeasured , popupWidth , roomAbove , roomBelow , roomLeft , roomRight , windowHeight , windowWidth } ) ; }
If we haven't already measured the popup since it was opened, measure its dimensions and the relevant distances in which the popup might be opened.
If we haven t already measured the popup since it was opened measure its dimensions and the relevant distances in which the popup might be opened .