如何在JQuery动画幻灯片中调整速度?

时间:2016-04-11 01:24:59

标签: jquery animation slide

我有一张快速转向的幻灯片,我需要帮助找出如何放慢速度。任何帮助将不胜感激!

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

这是所有代码



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
}




0 个答案:

没有答案