javascriptを使用して単純な画像ローテーターを作成しましたが、「古いブラウザー」(IE 6、7、8など)では低速です。画像が最初に読み込まれ、次にローテーターが起動します。高速化するためのヒントはありますか?
なぜ自分でローテーターを作ったのですか?私が見つけたすべてのローテーターは画像をカット(トリミング)しました。完全な画像が必要です...必要に応じて、左/右または上/下に空白を入れます。
Javascriptの部分:
//Loop through pictures
var tid = setInterval(mycode, 3000);
function mycode() {
if($.random(0,1) == 1){
//Fade
$('#alleplaatjes img.active').fadeOut(500,function(){
$(this).removeClass();
if($(this).next().length == 0){
$('#alleplaatjes img').first().fadeIn(500);
$('#alleplaatjes img').first().addClass('active');
} else {
$(this).next().fadeIn(500);
$(this).next().addClass('active');
}
});
} else {
//Slide
$('#alleplaatjes img.active').slideUp(500,function(){
$(this).removeClass();
if($(this).next().length == 0){
$('#alleplaatjes img').first().slideDown(500);
$('#alleplaatjes img').first().addClass('active');
} else {
$(this).next().slideDown(500);
$(this).next().addClass('active');
}
});
}
};
PHPの部分:
<?php
$dir = "/home/zwuq/domains/***/public_html/afbeelding/";
foreach(glob($dir."*") as $file){
$afbeelding = 'afbeelding/'.str_replace($dir, '', $file);
$toevoeging = FALSE;
if(!$eerste_plaatje){
$toevoeging = ' class="active"';
$eerste_plaatje = $afbeelding;
}
$plaatjes .= '<img'.$toevoeging.' src="'.$afbeelding.'" style="max-width: 99%; max-height: 99%;">';
}
?>
HTML部分:
<div id="alleplaatjes" style="width:100%; height:100%; margin:0px; padding:0px; z-index:1; text-align: center;">
<? echo $plaatjes; ?>
</div>