NoSleep.js
Prevent display sleep and enable wake lock in all Android and iOS web browsers.
Check out the live demo in any Android or iOS web browser.
Installation
This library is available on Bower as nosleep.
$> bower install nosleep
Alternatively, you can manually add NoSleep.js to your project (or the minified version).
Build from source
This repository uses webpack to build the distribution versions of the library. To build this library run webpack
.
Usage
Create a new NoSleep object and then enable or disable it when needed as follows:
var noSleep = new NoSleep();
function enableNoSleep() {
noSleep.enable();
document.removeEventListener('touchstart', enableNoSleep, false);
}
document.addEventListener('touchstart', enableNoSleep, false);
noSleep.disable();
License
MIT. Copyright (c) Rich Tibbett