source: imaps-frontend/node_modules/react-use/lib/usePageLeave.js

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

Update repo after prototype presentation

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