私は、各画像に対して10個のスライスを作成し、そのスライスをアニメーション化するスライドショーを持っています。つまり、オペラ、クロムはアニメーションはうまくいきますが、Firefoxではアニメーションが遅すぎます。私は別のコンピュータで試してみましたが、それでも同じです。私は10個の新しいdivを作成する "for"ループでスライスを作成し、各divは異なる背景位置のプロパティを持っています。どのように私はこれをfirefoxのために解決することができますか?ありがとう。FirefoxでのJqueryのアニメーションの速度
私はいくつかのコード
//part of creating slices
for(imageN=0;imageN<imageCount;imageN++)
{
$('#image').append("<div name=slices class=slices></div>");
slicesCreate(imageN);
}
//#image is main div contains slice divs.
//Here is sliceCreate function
/*In this function, it takes how many images added to slideshow, takes all
sources for each image and creates slices*/
function slicesCreate(imageN)
{
var i = 0;
var nleft = 0;
var image= $("#image img:eq("+imageN+")").attr("src");
for(i=0;i<10;i++)
{
$('.slices:eq('+imageN+')').append("<div name=slice"+i+" class=slice></div>");
$(".slices:eq("+imageN+") .slice[name=slice"+i+"]").css({
backgroundImage: "url("+image+")",
backgroundPosition: nleft + "px 0px",
backgroundRepeat: "no-repeat",
backgroundSize: twidth
});
/*sliceCount is a global variable that calculated when page loaded for display
resolution*/
nleft -=sliceCount;
}
}
/* And here is one of the animation code, this code runs for every slice */
function animateSlices(current,next,slice,animid,delay)
{
setTimeout(function() {
$(".slices:eq("+next+") .slice[name=slice"+slice+"]").css({
display: "block",
marginTop: "-700px"
});
$(".slices:eq("+next+") .slice[name=slice"+slice+"]").animate({
marginTop: "0px"
},1000);
$(".slices:eq("+current+") .slice[name=slice"+slice+"]").animate({
marginTop: "700px"
},1000);
}, delay);
}
そして、あなたはアニメーションボタン
function anim()
{
if(!animating)
{
animating = true;
var j = 0;
var delay = 0;
current = $('.slices:visible').index('.slices');
var siz = $('.slices').size();
var cSize = $('.slices:visible').size();
var txen = 2;
var rand = parseInt(Math.random()*3);
var last = $('.slices:last').index('.slices');
if(cSize>1)
return;
//this part is calculating id of next image
if(siz > 1 && current!= last)
{
txen = current + 1;
}
else if(siz == 1)
{
txen = current;
}
else if(siz > 1 && current== last)
{
txen = 0;
}
//this part is makin next image slices visible and changes z-index for animation
$(".slices:eq("+txen+")").css({
display: "block",
zIndex: "92"
});
$(".slices:eq("+current+")").css({
zIndex: "91"
});
//this part calls animateSlices function for every next image slices
for(j=0;j<10;j++)
{
$(".slices:eq("+txen+") .slice[name=slice"+j+"]").css({
marginTop: "0px"
});
animateSlices(current,txen,j,rand,delay);
/*current = this image, txen = next image, j = slice number, rand = animation id,
delay = delay for animation */
if(rand==0)
delay += 150;
else
delay += 50;
}
}
else
return;
}
編集]をクリックしたときに呼び出される関数を追加しました:私はアニメーションで「トップ」に「marginTop」を変更したのと各スライスの絶対的な位置、現在解決されている問題、それはもはや遅れていません。私はjqueryコードでdivを配置することについていくつかのエラーを抱えていたか、同じマージンを多く変更すると遅れが生じるかもしれませんが、私はfirefoxでしか起こっていないと言いました。その遅れの原因を知っていないが、私はこれを解決するとき私はここで私の解決策を記述します。今のところ私はmarginTopの最高値instedを変更します。誰もお返事ありがとうございます。
http://api.jquery.com/animate/を使用してみませんか? –
アニメーションコードはどのように見えますか?例は実際に問題の理解に役立ちます。 –
あなたはすべてのブラウザで異なるアニメーションのスピードを経験します。 IE7であなたのアニメーションを見てからFFがどれほど遅いかを見てみましょう。とにかく、アニメーションコードを貼り付ける必要があります。あなたの説明でメソッドが私に奇妙に聞こえ、jqueryアニメーションがたくさんあります。 –