How to adjust the speed in JQuery animation slide?

I have a slide that is turning way to fast and I need help figuring out how to slow it down. Any help would be greatly appreciated!

[http://catchieconcepts.com/][1]

this is all the code

jQuery(document).ready(function($){
	var w,mHeight,tests=$("#testimonials");
	w=tests.outerWidth();
	mHeight=0;
	tests.find(".testimonial").each(function(index){
		$("#t_pagers").find(".pager:eq(0)").addClass("active");	//make the first pager active initially
		if(index==0)
			$(this).addClass("active");	//make the first slide active initially
		if($(this).height()>mHeight)	//just finding the max height of the slides
			mHeight=$(this).height();
		var l=index*w;				//find the left position of each slide
		$(this).css("left",l);			//set the left position
		tests.find("#test_container").height(mHeight);	//make the height of the slider equal to the max height of the slides
	});
});



$(".pager").on("click",function(e){	//clicking action for pagination
e.preventDefault();
next=$(this).index(".pager");
clearInterval(t_int);	//clicking stops the autoplay we will define later
moveIt(next);
});



function moveIt(next){	//the main sliding function
	var c=parseInt($(".testimonial.active").removeClass("active").css("left"));	//current position
	var n=parseInt($(".testimonial").eq(next).addClass("active").css("left"));	//new position
	$(".testimonial").each(function(){	//shift each slide
		if(n>c)
			$(this).animate({'left':'-='+(n-c)+'px'});
		else
			$(this).animate({'left':'+='+Math.abs(n-c)+'px'});
	});
	$(".pager.active").removeClass("active");	//very basic
	$("#t_pagers").find(".pager").eq(next).addClass("active");	//very basic
}

Answers 1

  • Look at jQuery animate There is ja duration parameter. e.g.:

    $(this).animate({'left':'-='+(n-c)+'px'}, 1000);
    

    Duration is in ms and default is set to 400ms.


Related Articles