PDA

View Full Version : Repeat jQuery animation every 5 sec



bokanegro
08-13-2010, 09:33 AM
Hello,

Jquery animation help needed. I'm using cycle plugin, and every slide have caption: h1 and p. Animation created for caption is below but don't know how to repeat every 5 sec.

h1 and 5 sliding from left and after 3 sec they slide back (to left) again.



jQuery('.description h1').delay(400).animate({left: '0px' }, 700, 'easeOutBack').delay(3000).animate({left: '-650px' }, 700, 'easeOutBack');
jQuery('.description p').delay(500).animate({left: '0px' }, 700, 'easeOutBack').delay(3200).animate({left: '-650px' }, 700, 'easeOutBack');


Grateful for any help
Thanks

Beverleyh
08-13-2010, 11:49 AM
Look into "everyTime()" - timers plugin for jQuery: http://plugins.jquery.com/project/timers

See;

everyTime(interval : Integer | String, [label = interval : String], fn : Function, [times = 0 : Integer])
everyTime will add the defined function (fn) as a timed event to run at a given time interval (interval) for a given number of times (times). If times is set to 0, the number of times the method is called is unbounded.

bokanegro
08-13-2010, 01:37 PM
Hi Beverleyh,

I tried timers plugin before started this thread... and didn't fit my needs. I found perfect solution for caption in cycle plugin:



$('#slideshow').cycle({
before: onBefore,
after: onAfter
});

function onBefore() {
$('p').hide();
}
function onAfter() {
$('p').css({opacity: '0.5'}).slideDown('slow');
}


Thanks to Paul from
http://old.nabble.com/ (http://old.nabble.com/Need-solution-to-cycle-through-images-and-display-a-caption-td19830233s27240.html#a19885126)