Question

I found this pulsing effect online and it works fine but it is set to only work on hover. I would like it to be a constant effect and not sure how to adjust it to remove the hover requirement. The callbacks in jquery always throw me off a bit in reading the code. I'm learning..little bit at a time. Any help would be great.

$(function(){
$.extend($.fn.pulse = function(){
var minOpacity = .33;
var fadeOutDuration = 400;
var fadeInDuration = 400;
$(this).attr( 'pulsing', 'y' );

$(this).animate({
opacity: minOpacity
}, fadeOutDuration, function() {
$(this).animate({
opacity: 1
}, fadeInDuration, function() {
if( $(this).attr('pulsing') == 'y' ) $(this).pulse();
})
});
return $(this);
});
$.extend($.fn.stopPulse = function(){
$(this).attr( 'pulsing', '' ).stop(true,true).animate({opacity:1});
});

$('.pulse_image').(function(){ $(this).pulse() },function(){ $(this).stopPulse() });
Was it helpful?

Solution

Surely you can just do:

$('.pulse_image').pulse();

DEMO: http://jsfiddle.net/bC7pS/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top