galleryViewでの画像のプリロードのネイティブサポートはないようです。仕様から:
将来のバージョンで画像のプリロードを検討します
だからあなたはあなた自身を転がさなければなりません。
jQuery.load()
関数を見てください。
ロードされたら最初の画像を表示し、次に他の画像をバックグラウンドでロードします。
id
最初の画像が=にあるとしましょうfirst
$(function() { // <== doc ready
// do something after first image is loaded
$("#first").load( /* show the first image */ );
// do something after all images loaded
$("img").load( /* do the main gallery loop */ )
});
必要に応じて上記を変更してください。最初の大きな画像と最初の5つのサムネイルなどを表示したい場合を考えてみましょう。
これが私が始める方法です。最初の画像だけでなく、最初の親指の列を埋めるのに必要な数の画像をプリロードすると、おそらくスムーズに見えると思います。
div
すべての画像が読み込まれるまで、1つの画像だけで一時的な画像を表示します。
HTML:
<div id="temp"></div>
<div id="photos" class="galleryview">
<img id="first" ... />
<img ... />
<img ... />
<img ... />
...
</div>
JS:
$(function() { // <== doc ready
var $photos = $("#photos"), $temp = $("#temp"),
$first = $("#first");
// Hide gallery:
$photos.hide();
// show temp when 1st img loaded
$first.load( $temp.append( $first.clone() ) );
// To make things look smooth you can also make
// a quick gallery view out of temp. This only has 1 image.
$temp.galleryView({
panel_width: 800,
panel_height: 300,
frame_width: 100,
frame_height: 100,
});
// do full gallery when all imgs loaded
$("img").load(
// remove the temp gallery
$temp.remove();
// show gallery
$photos.galleryView({
panel_width: 800,
panel_height: 300,
frame_width: 100,
frame_height: 100,
});
);
});