jInsects

jInsects is a jQuery plugin which generates bugs under the specified element which then run off screen.

This concept for this idea came from Lee Musgrave and the implementation by Tom Oram.

Demonstration

Hover Over Me!

I am a popup

What is hiding underneath me?

Download

Current Version: Download

Development Version: https://github.com/tomphp/jquery.insects

Usage

Include jQuery and jInsect into your HTML page:

Call $.insectify() on the element you want to apply insects to:

A typical use for this plugin would be to have insects hiding under a popup,
this can be done like so:

Please note that $.insectify() must be called before $.hide() as it needs the element to be displayed when it is called so it can get the position.

The above code would work on some HTML similar to this:

Options can be passed to the $.insectify() method like so:

For a list of all available objects see the next section.

Options

  • max-insects: The maximum number of insects that could be hiding under the
    element.
    • Type: Integer
    • Default: 3
  • chance: The chance that there will be insects hiding. A value of 1 means
    there will always be insects hiding.
    • Type: Float
    • Range: 0-1
    • Default: 0.5
  • min-speed: The minimum possible speed of an insect.
    • Type: Integer
    • Range: 1-10 recommended
    • Default: 5
  • max-speed: The maximum possible speed of an insect.
    • Type: Integer
    • Range: 1-20 recommended
    • Default: 15
  • update-freq (Integer): The time between updates of the insect sprites in
    milliseconds. Lower is smoother but more CPU intensive.
    • Type: Integer
    • Range: 1-1000
    • Default: 50

Leave a Reply

Your email address will not be published. Required fields are marked *