@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.

Readme

Keywords

Package Sidebar

Install

npm i @automattic/popup-monitor

Weekly Downloads

835

Version

1.0.2

License

GPL-2.0-or-later

Unpacked Size

13.7 kB

Total Files

6

Last publish

Collaborators

  • porada
  • imranh920
  • gmjuhasz
  • rcarvalho
  • briowill
  • bgrgicak
  • dhenridev
  • daledupreez-a8c
  • jeherve
  • yuliyan
  • micbosia8c
  • jeremy.yip
  • wpvip-bot
  • etobiesen
  • kzoschke
  • brunobasto
  • kat3samsin
  • fmfernandes
  • newspack
  • robertsreberski_a8c
  • msurdi-a8c
  • chihsuan
  • manzoorwanijk
  • rjchow
  • andrea-sdl
  • scjr
  • spsiddarthan
  • t2dw4t
  • ehg_
  • wwa
  • sirreal
  • elazzabi
  • royho
  • luismulinari
  • macbre
  • mjangda
  • matticbot
  • a8c
  • blowery
  • noahtallen
  • hanifn
  • sgomes
  • tyxla
  • saroshaga
  • parkcityj
  • nejclovrencic
  • sirbrillig
  • chriszarate
  • robersongomes
  • johngodley