Skip to content

Displays a 'screensaver' in a sandbox element after a configurable amount of seconds of no user input

License

Notifications You must be signed in to change notification settings

Tyriar/web-screensaver

Repository files navigation

web-screensaver NPM version

Displays a 'screensaver' in a sandbox element after a configurable amount of seconds of no user input. Supports multiple types of screensaver plugins that are randomly selected. Downloading of individual plugins are deferred until they're required so impact on page load time is minimal.

Installing

# via bower
bower install --save web-screensaver

# via npm
npm install --save web-screensaver

Including

<script src="bower_components/web-screensaver/web-screensaver.js"></script>

Usage

// Register plugin-url.js, wait the default time after no input
webScreensaver.init('plugin-url.js');

// Register plugin-url.js, wait for 2 minutes after no input
webScreensaver.init('plugin-url.js', 120);

// Register multiple plugins
webScreensaver.init([
  'plugin-url1.js',
  'plugin-url2.js'
], 120);

Creating plugins

Plugins are the scripts that actually do the visual work, the framework calls in to start and stop functions on the plugin which set everything up and tear everything down respectively. Here is the structure of a plugin:

webScreensaver.registerPlugin((function () {
  var module = {};

  module.start = function (sandbox) {
    // Start the screensaver
  };

  module.stop = function () {
    // Stop the screensaver
  };

  return module;
})());

License

MIT © Daniel Imms

About

Displays a 'screensaver' in a sandbox element after a configurable amount of seconds of no user input

Resources

License

Stars

Watchers

Forks

Packages

No packages published