= Math.round(anchorRect.right - offset)) ? 1 : 0; let vertPos = (Math.round(popupRect.bottom) <= Math.round(anchorRect.top + offset)) ? -1 : (Math.round(popupRect.top) >= Math.round(anchorRect.bottom - offset)) ? 1 : 0; let HALF_ARROW_WIDTH = 16; let anchorClass = ""; let hideArrow = false; if (horizPos == 0) { container.orient = "vertical"; arrowbox.orient = ""; if (vertPos == 0) { hideArrow = true; } else { arrowbox.style.marginLeft = ((anchorRect.left - popupRect.left) + (anchorRect.width / 2) - HALF_ARROW_WIDTH) + "px"; if (vertPos == 1) { container.dir = "ltr"; anchorClass = "top"; } else if (vertPos == -1) { container.dir = "reverse"; anchorClass = "bottom"; } } } else if (vertPos == 0) { container.orient = ""; arrowbox.orient = "vertical"; arrowbox.style.marginTop = ((anchorRect.top - popupRect.top) + (anchorRect.height / 2) - HALF_ARROW_WIDTH) + "px"; if (horizPos == 1) { container.dir = "ltr"; anchorClass = "left"; } else if (horizPos == -1) { container.dir = "reverse"; anchorClass = "right"; } } else { hideArrow = true; } arrow.hidden = hideArrow; arrow.setAttribute("side", anchorClass); ]]>