JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 75
  • Score
    100M100P100Q86623F
  • License MIT

Positions a popup element to an anchor element.

Package Exports

  • position.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (position.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

position.js

😉

Usage

Positions a popup element to an anchor element:

const {left, top} = position(popup, anchor, 'top')
Object.assign(popup.style, {left: `${left}px`, top: `${top}px`})

API

position(popup, anchor, preset, options)

Options

{
  // use fixed or absolute position, defaults to false
  fixed: false,
  // any scroller element, defaults to document.body
  offsetParent: document.body,
}

Presets

  • top
  • right
  • bottom
  • left
  • center
  • top-left
  • top-right
  • right-top
  • right-bottom
  • bottom-left
  • bottom-right
  • left-top
  • left-bottom

Combos

position(popup, anchor, {popup: 'left-top', anchor: 'right-top'})
// same as `right-top` preset
position(popup, anchor, 'right-top')