nosleep

2018-07-11 admin

nosleep是什么

什么是nosleep,Prevent display sleep on all Android and iOS browsers

nosleep介绍、nosleep使用

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

This package is published to npm as nosleep.js and can be installed with:

$> npm install nosleep.js

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('click', enableNoSleep, false);
}

// Enable wake lock.
// (must be wrapped in a user input event handler e.g. a mouse or touch handler)
document.addEventListener('click', enableNoSleep, false);

// ...

// Disable wake lock at some point in the future.
// (does not need to be wrapped in any user input event handler)
noSleep.disable();

License

MIT. Copyright © Rich Tibbett

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-35769.html

文章标题:nosleep

回到顶部