Auz / Bug

Add bugs to your website
https://auz.github.io/Bug/
435 stars 80 forks source link

Bug

Add bugs to your page.

Features

Demo

See project page: http://auz.github.io/Bug/

Dependencies

None, all native js code

Compatibility

Works on all browsers that support CSS3 transforms, even mobile (that I've tested).

See http://caniuse.com/transforms2d

How to use

Include the JS somewhere, and then initialize with

  new BugController();

or

  new BugController({'minBugs':10, 'maxBugs':50, 'mouseOver':'die'});

You can use SpiderController() as a shortcut for loading options and the sprite for the spiders.

  new SpiderController({'minBugs':2, 'maxBugs':6});

See example.html

BugController constructor can optionally take an object of options. To make this js more async friendly, you can adjust the default options at the top of bug.js, and then instantiate at the bottom of the file as above. This will allow one to wrap the entire script in a closure to prevent any global window name space overlaps.

Async code:

  var targethead = window.document.getElementsByTagName("head")[0],
    loadedSpiders = false,
    jst = window.document.createElement("script");
  jst.async = true;
  jst.type = "text/javascript";
  jst.src = "/path/to/bug-min.js";
  jst.onload = jst.onreadystatechange = function() {
    if (!loadedSpiders && (!this.readyState || this.readyState == 'complete')) {
      loadedSpiders = true;
      // start fire the JS.
      new BugController();
    }
  };
  targethead.appendChild(jst);

Options

Modes

Credits

Original Screen Bug http://screen-bug.googlecode.com/git/index.html

Released under WTFPL license.