JSPM

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

Popups, tooltips and overlays

Package Exports

  • popoff

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 (popoff) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Popov

Popoff unstable

Popoff runs modals, tooltips, popups, dropdowns, confirms, notifiers, popovers, lightboxes, balloons, dialogs, alerts, overlays, sidebars etc. Demo.

Usage

npm install popoff

var createPopup = require('popoff');

//create and show modal
var modal = createPopup({
    type: 'modal',
    content: `
        <h2>Blah</h2>
        <p>blah</p>
    `
});
modal.show();

//create and show dropdown
var dropdown = createPopup({
    target: '#menu',
    type: 'dopdown',
    content: document.querySelector('#content')
});
document.querySelector('#menu').click();

API

var popup = new Popup({
    // modal, dropdown, tooltip, sidebar work out of the box. Otherwise define custom options below. See demo for examples.
    type: 'modal',

    // target element that enables the popup, e.g. button.
    target: null,

    // an element to place popup into
    container: document.body || document.documentElement,

    // show overlay, will be detected based off type
    overlay: true,

    // show close button
    closable: true,

    // close by escape
    escapable: true,

    // show tip
    tip: false,

    // animation effect, see effects in the demo page
    effect: 'fade',

    // additional style rules for popup
    style: {},

    // shift main content on defined amount. Useful in case of sidebars
    shift: 120
});

//show popup relative to the target, invoke callback after animation end
popup.show(target?, callback?);

//hide popup, invoke callback after animation end
popup.hide(callback?);

//update popup position, in case of resize etc.
popup.update({
    target: this._target || this.target,
    side: this.side,
    align: this.align,
    within: window
});

//events
popup.on('show', () => {});
popup.on('afterShow', () => {});
popup.on('hide', () => {});
popup.on('afterHide', () => {});
popup.on('update', () => {});

Credits

Popoff engages practices of old overlay-component and dialog-component, refined and mixed with modern ES6 and browserify component approaches. List of effects is taken from modal window effects article from codrops, so big thanks to them for awesome lib.

See also

  • prama — settings page constructor.
  • placer — place any element relative to any other element in any way.
  • aligner — align elements set by one or other side.