jQuery Pulse Animation Plugin
The purpose of this plugin was to make it trivial to add subtle visual cues to any web page. JQuery offers plenty in the way of simple effects but this was written to automate successive, identical transitions and the return to the original state.
This is a very light amount of code and, unless something drastic changes to the core of jQuery.animate, it should be future proof for quite some time. It should be as cross browser compatible as jquery is and the examples on this page have been tested on multiple browsers, OSes, and devices.
$('.selector').pulse(css [, options] [, callback]);
To stop any given pulse, issue a 'destroy' command on a pulsing element
$('.selector').pulse('destroy');
pulses
( default 1 )The number of full pulses to and from property states. -1 makes the pulse last forever
duration
( default 500 )The full time for a round trip
interval
( default 0 )The interval between two pulses
returnDelay
( default 0 )The delay before issuing the return animation
This line of text will pulse red twice quickly
This block will widen 3 times a little more slowly
The same property syntax applies for this as it does with jQuery. For example, you can not use css shorthand. You must specify properties individually.
You can use the interval argument to specify a duration in between the animations. Now breathe deeply!
You can pulse anything jQuery already lets you animate, or much more if you also use jQueryUI!
It also respects jQuery's concept of chaining and operating on multiple elements. (Subsequent chains, though, execute immediately)
This will pulse blue until 'destroy' is called (10 seconds). Subsequent runs of pulse with the same properties will collide and produce unexpected (but often neat) results.
This example uses the callback to chain successive pulses.
This shows the use of the return delay. The background color will pulse between white and purple with 1s delays between all animations
Copyright (c) 2012, Jarrod Overson All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JARROD OVERSON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.