UNPKG

atriusmaps-node-sdk

Version:

This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information

36 lines (33 loc) 957 B
'use strict'; const callbacks = /* @__PURE__ */ new Set(); let listenerStarted = false; let userInteracted = false; function userInteractionHandler() { if (!userInteracted) { userInteracted = true; for (const cb of callbacks) { cb(true); } callbacks.clear(); } document.body.removeEventListener("click", userInteractionHandler); document.body.removeEventListener("keydown", userInteractionHandler); } function startInitialStateListener() { if (listenerStarted) { return; } listenerStarted = true; if (typeof window === "undefined" || window.document?.body == null) { userInteracted = true; return; } if (performance.now() > 1e4) { userInteracted = true; return; } userInteracted = false; document.body.addEventListener("click", userInteractionHandler); document.body.addEventListener("keydown", userInteractionHandler); } exports.startInitialStateListener = startInitialStateListener;