'Pulse' is a recently developed jQuery plugin which applies a continual pulse to any element specified. 'Pulseable' properties include "background-color', 'color', 'border-color' and 'opacity'. You can see the realted blog post here: "ENHANCE :: New jQuery plugin: Pulse".
Download jQuery and Pulse.jquery.js and link to them both:
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="pulse.jquery.js"></script>
Using the "pulse" plugin for jQuery is very simple. In order to get started you need to specify an element which is to be pulsed:
$('#my-element').pulse();
The above code WILL NOT work by itself. You need to specify some options. The available options include: (click each for more info)
To stop an element from pulsing simply use 'recover':
$('#elem').recover();
It's possible to pulse more than one property, so you could have the following:
$('#elem').pulse({
backgroundColors: ['red','blue','green','magenta'],
textColor: ['black','yellow','white'],
borderColors: ['yellow','blue','purple','green','orange'],
opacityRange: [0.3, 0.8]
});
The script will pulse through each specified color/opacity within it's own, meaning that each property can have a different number of color/opacity values. This diagram illustrates how the above code would work:
The above image shows the order in which the colors would change, each step would take 1000 milliseconds since that is the default speed. Obviously you can change this by specifying your own speed.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque nunc sem, placerat sit amet, posuere in, bibendum vel, quam. Vivamus aliquam augue et erat. Nulla facilisi. Maecenas mauris ante, posuere vel, porttitor non, pellentesque mattis, justo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus porttitor scelerisque elit. Cras nunc pede, pellentesque non, molestie et, elementum eu, elit. Ut odio eros, pellentesque nec, rutrum ut, pharetra quis, enim. Pellentesque blandit scelerisque erat. Mauris mattis, quam sit amet pretium hendrerit, nulla velit varius enim, et ullamcorper lectus urna nec ligula. Morbi et risus. In mi. Vestibulum vel nisi quis justo sagittis tempor.
$('p#opacity-demo').pulse({
speed: 500,
opacityRange: [0.4,0.9]
});
(with PNG gradient overlay)
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque nunc sem, placerat sit amet, posuere in, bibendum vel, quam. Vivamus aliquam augue et erat. Nulla facilisi. Maecenas mauris ante, posuere vel, porttitor non, pellentesque mattis, justo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus porttitor scelerisque elit. Cras nunc pede, pellentesque non, molestie et, elementum eu, elit. Ut odio eros, pellentesque nec, rutrum ut, pharetra quis, enim. Pellentesque blandit scelerisque erat. Mauris mattis, quam sit amet pretium hendrerit, nulla velit varius enim, et ullamcorper lectus urna nec ligula. Morbi et risus. In mi. Vestibulum vel nisi quis justo sagittis tempor.
$('p#basic-bg-demo').pulse({
backgroundColors: ['#00dc1f','#0072f3']
});
WARNING, SOMETHING JUST HAPPENED!
$('p#alert-box-demo').pulse({
backgroundColors: ['#ffffff','#dedede'],
textColors: ['#de0000','#ff0000'],
borderColors: ['red','yellow'],
speed: 500
});
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque nunc sem, placerat sit amet, posuere in, bibendum vel, quam. Vivamus aliquam augue et erat. Nulla facilisi. Maecenas mauris ante, posuere vel, porttitor non, pellentesque mattis, justo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus porttitor scelerisque elit. Cras nunc pede, pellentesque non, molestie et, elementum eu, elit. Ut odio eros, pellentesque nec, rutrum ut, pharetra quis, enim. Pellentesque blandit scelerisque erat. Mauris mattis, quam sit amet pretium hendrerit, nulla velit varius enim, et ullamcorper lectus urna nec ligula. Morbi et risus. In mi. Vestibulum vel nisi quis justo sagittis tempor.
$('p#rainbow-demo').pulse({
backgroundColors: ['red','orange','yellow','green','blue','indigo','violet'],
textColors: ['white','black','black','white','white','white','white']
});
(Using a PNG as the <IMG/>)
$('#png-photo').pulse({
backgroundColors: ['#eeae00','#ffdf5e'],
speed: 500
});
Copyright © 2008 James Padolsey