source: imaps-frontend/node_modules/react-use/esm/usePageLeave.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 690 bytes
RevLine 
[d565449]1import { useEffect } from 'react';
2import { off, on } from './misc/util';
3var usePageLeave = function (onPageLeave, args) {
4 if (args === void 0) { args = []; }
5 useEffect(function () {
6 if (!onPageLeave) {
7 return;
8 }
9 var handler = function (event) {
10 event = event ? event : window.event;
11 var from = event.relatedTarget || event.toElement;
12 if (!from || from.nodeName === 'HTML') {
13 onPageLeave();
14 }
15 };
16 on(document, 'mouseout', handler);
17 return function () {
18 off(document, 'mouseout', handler);
19 };
20 }, args);
21};
22export default usePageLeave;
Note: See TracBrowser for help on using the repository browser.