Positions a popup element to an anchor element.
npm install position.jsPositions a popup element to an anchor element 😉



``js
const {
placement, // actual placement
popupOffset, // CSS position: {left, top}
arrowOffset, // CSS position: {left, top}
popupRect,
anchorRect,
} = position(popup, anchor, 'top', options)
// DOM
Object.assign(popup.style, popupOffset)
// React
`
position(popup, anchor, placement, options)
`js`
{
// use fixed or absolute position, defaults to false
fixed: false,
// any scroller element, defaults to document.body
offsetParent: document.body,
// 'auto': adjusts horizontally or vertically, 'both': adjusts horizontally and vertically, defaults to 'none'
adjustXY: 'none',
}
- topright
- bottom
- left
- center
- top-left
- top-right
- right-top
- right-bottom
- bottom-left
- bottom-right
- left-top
- left-bottom
-
`right-top
position(popup, anchor, {popup: 'left-top', anchor: 'right-top'})
// same as placement``
position(popup, anchor, 'right-top')