Manipulate The Position Of Elements Using Placement.js Library

Category: Javascript | September 7, 2019
Author: tobyzerner
Views Total: 119 views
Official Page: Go to website
Last Update: September 7, 2019
License: MIT

Preview:

Manipulate The Position Of Elements Using Placement.js Library

Description:

Placement.js is an alternative to the Popper.js that provides a simple way to manage the position of an element (e.g. popup, tooltip, popover, dropdown, etc) relative to other elements.

How to use it:

Install the package and import the Placement.js module.

# NPM
$ npm install placement.js --save
import placement from 'placement.js';

Initialize the placement and pass the following parameters:

  • anchor: anchor element
  • popup: popup element to position
  • side: ‘top’, ‘bottom’, ‘left’, or ‘right’
  • align: ‘start’, ‘center’, or ‘end’
  • options: options object, see below
placement(anchor, popup, side, align, options)

Apply the position: fixed property to the popup element.

options = {
  fixed: false // true or false
}

You Might Be Interested In:


Leave a Reply