jQueryサイクルのスライドショーを含むページでJavaScriptウィンドウのサイズ変更スクリプトを実行しようとしていますが、うまくいかないように見えるいくつかのバグにぶつかっています。ページの読み込み時に最初の画像のサイズを変更しますが、後続のスライドの新しい高さ/幅の属性を忘れます。jQuery を使用する前後にこれらを再度設定することはできますが、サイズを変更する前に、画像は常にフル サイズで一瞬一瞬表示されます。
jQuery.cycle はスライドを元のサイズにサイズ変更していますか? もしそうなら、どうすればこれを止めることができますか?
$(document).ready(function () {
$('.slideshow').cycle({
fx: 'fade',
speed: 200,
timeout: 1000,
pause: 1,
before: function (currSlideElement, nextSlideElement, options, forwardFlag) {
resize();
},
after: function (currSlideElement, nextSlideElement, options, forwardFlag) {
resize();
}
});
$('.slideshow').find('img').css("height", "0");
$('#image').hide().idle(1000).fadeIn();
resize();
});
$(window).resize(function () {
resize();
});
function resize() {
var theheight = window.innerHeight;
var thewidth = window.innerWidth;
var imageheight = theheight - 200;
if (imageheight > 540) {
imageheight = 540;
}
if (imageheight < 300) {
imageheight = 300;
}
var imagewidth = imageheight / 0.6585365;
$(".slide").css("height", imageheight);
$(".slide").css("width", imagewidth);
$(".slide").attr("height", imageheight);
$(".slide").attr("width", imagewidth);
}