1 Matching Annotations
  1. Feb 2022
    1. Reacquiring a wake lock

      The following code reacquires the wake lock should the visibility of the document change and the wake lock is released.

      js document.addEventListener('visibilitychange', async () => { if (wakeLock !== null && document.visibilityState === 'visible') { wakeLock = await navigator.wakeLock.request('screen'); } });