Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/derhuerst/window-on-print
Reliably detect when the user prints.
https://github.com/derhuerst/window-on-print
browser frontend print
Last synced: 6 days ago
JSON representation
Reliably detect when the user prints.
- Host: GitHub
- URL: https://github.com/derhuerst/window-on-print
- Owner: derhuerst
- License: isc
- Created: 2016-11-30T23:51:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-11-08T21:14:40.000Z (about 2 years ago)
- Last Synced: 2024-10-30T07:46:25.375Z (15 days ago)
- Topics: browser, frontend, print
- Language: JavaScript
- Homepage: http://derhuerst.github.io/window-on-print/example.html
- Size: 59.6 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# window-on-print
**Reliably detect when the user prints.** A better solution for [`beforeprint`](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeprint)/[`afterprint`](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint).
[![npm version](https://img.shields.io/npm/v/window-on-print.svg)](https://www.npmjs.com/package/window-on-print)
[![build status](https://img.shields.io/travis/derhuerst/window-on-print.svg)](https://travis-ci.org/derhuerst/window-on-print)
[![dependency status](https://img.shields.io/david/derhuerst/window-on-print.svg)](https://david-dm.org/derhuerst/window-on-print)
[![dev dependency status](https://img.shields.io/david/dev/derhuerst/window-on-print.svg)](https://david-dm.org/derhuerst/window-on-print#info=devDependencies)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/window-on-print.svg)
[![support me on Patreon](https://img.shields.io/badge/support%20me-on%20patreon-fa7664.svg)](https://patreon.com/derhuerst)## Installing
```shell
npm install window-on-print
```## Usage
```js
const onPrint = require('window-on-print')const unsubscribe = onPrint.before(window, () => {
console.info('user is going to print')
})
onPrint.after(window, () => {
console.info('user is has printed or aborted')
})
```You may call `unsubscribe()` to stop listening for events.
## Contributing
If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/window-on-print/issues).