1.2.1 • Published 7 years ago

floaties v1.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

floaties

npm Travis Codecov

Simple helpers for creating popups.

  • Snap any popup corner to any target corner
  • Uses bottom, height, left, right, top, and width to keep the popup fully on-screen at all times
    • Combine with overflow: auto; in the popup element to make sure content is always available.

snap

Mutates input popup element, setting styles required to achieve desired popup position relative to target.

import { snap } from 'floaties';

const popupEl = document.querySelector('.my-popup');
const targetEl = document.querySelector('.my-target');

snap({
  popupEl,
  targetEl,
});

getStyle

Returns object with styles required to achieve desired popup position relative to target. Popup position defaults to top-left of popup aligned with top-left of target.

import { getStyle } from 'floaties';

const popupEl = document.querySelector('.my-popup');
const targetEl = document.querySelector('.my-target');

const style = getStyle({
  popupEl,
  targetEl,
});

Options

PropertyTypeDescriptionDefault Value
popupElHTMLElementThe popup element which should be positioned relative to the target.N/A
popupHorizontalStringThe side of the popup that should be attached to the target side specified in targetHorizontal. Possible values are 'left' and 'right'.'left'
popupVerticalStringThe side of the popup that should be attached to the target side specified in targetVertical. Possible values are 'top' and 'bottom'.'top'
targetElHTMLElementThe target element to which the popup should be positioned relatively.N/A
targetHorizontalStringThe side of the target to which the side of the popup specified in popupHorizontal should be attached. Possible values are 'left' and 'right'.'left'
targetVerticalStringThe side of the target to which the side of the popup specified in popupVertical should be attached. Possible values are 'top' and 'bottom'.'top'
1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.0

7 years ago