@automattic/popup-monitor

1.0.2 • Public • Published

Popup Monitor

Popup Monitor is a small utility to facilitate the monitoring of a popup window close action, which is especially useful for temporary popup windows (e.g. an authorization step).

Usage

A Popup Monitor instance offers an open function which accepts an identical set of arguments as the standard window.open browser offering. When the window is closed, a close event is emitted to the instance with the name of the closed window.

import PopupMonitor from '@automattic/popup-monitor';

const popupMonitor = new PopupMonitor();

popupMonitor.open( 'https://wordpress.com/', 'my-popup' );

popupMonitor.on( 'close', function ( name ) {
	if ( 'my-popup' === name ) {
		console.log( 'Window closed!' );
	}
} );

Methods

  • open( url, name, features ): Proxies an identical call to window.open and begins to monitor the window open state.
  • getScreenCenterSpecs( width, height ): A helper method for generating a feature (specification) string of a specific width and height at the center of the user's screen.

/@automattic/popup-monitor/

    Package Sidebar

    Install

    npm i @automattic/popup-monitor

    Weekly Downloads

    1,385

    Version

    1.0.2

    License

    GPL-2.0-or-later

    Unpacked Size

    13.7 kB

    Total Files

    6

    Last publish

    Collaborators

    • macbre
    • yuliyan
    • mjangda
    • matticbot
    • a8c
    • blowery
    • ehg_
    • sgomes
    • tyxla
    • saroshaga
    • nejclovrencic
    • sirbrillig
    • chriszarate
    • robersongomes
    • johngodley
    • jeherve
    • daledupreez-a8c
    • t2dw4t
    • luismulinari
    • andrea-sdl
    • elazzabi
    • fmfernandes
    • sirreal
    • wwa
    • chihsuan
    • manzoorwanijk
    • msurdi-a8c
    • newspack
    • dsmartg
    • kthai15
    • bgrgicak
    • robertsreberski_a8c
    • artpi
    • gmjuhasz
    • kat3samsin
    • brunobasto
    • dhenridev
    • micbosia8c
    • mrmurphy
    • wpvip-bot
    • etobiesen
    • alshakero
    • arthur791004
    • dilirity
    • mattwest-a8c
    • mehmoodak
    • natalia.vidal
    • chriskmnds
    • oandregal
    • galatanovidiu
    • kangzj
    • _mirka_
    • aduth