jQuery animated picture
jQuery animated picture
Hi,
well I could need some help again.
We got some kind of slideshow on a website and the picture's are 'cause of the 100% width really big. it's jerking and it takes a lot of cpu. I wonder if there is a way to use not so much cpu while the animation is running.
Here's the code if it's needed.
-
$(document).ready(function(){
$("#slideshow img").css("display","none");
function run(elementnumber){
if (elementnumber == $("#slideshow img").length)
elementnumber = 0;
var slideshowheigh = $("#slideshow").height();
$("#slideshow img:eq("+elementnumber+")").css("margin-top", 0);
$("#slideshow img:eq("+elementnumber+")").css("display", "block");
$("#slideshow img:eq("+elementnumber+")").css("opacity", "0");
$("#slideshow img:eq("+elementnumber+")").show("normal",function(){
var speedie = 40000;
var imgheight = $(this).height();
var unten = imgheight - slideshowheigh;
var mitte = (imgheight/2) - (slideshowheigh/2);
$(this).css("margin-top", 0);
//fade(elementnumber);
$(this).animate({marginTop: -mitte,opacity:1},speedie, function (){
$(this).animate({marginTop: -unten,opacity:0},speedie, function (){
$(this).css("margin-top", 0);
$(this).slideUp(1, run(elementnumber+1));
});
});
});
};
run(0);
});
css
-
#slideshow{width:100%; height:290px; overflow:hidden; position:absolute; }
#slideshow img{ min-width:100%; }
thanks for any help.
-weidc