私はプロジェクトに Masonry を使用しており、それに応じて imagesLoaded を適用しています。
何度も何度もテストした結果、これら 2 つはほぼ完全に連携して動作することがわかりましたが、失敗することもあります。99% の場合は imagesLoaded のせいです。
ただし、Internet Explorer では、imagesLoaded は他のどのブラウザーよりも多くの読み込みに失敗するようです。
これが私が見つけたものです:
- 新しいタブを開いてURLを直接入力すると-> imagesLoadedが動作します
- 更新を押すと-> imagesLoadedが機能します
- URL を入力した場合は、[更新] をクリックし、アドレス バーのテキストをマークして Enter キーを押します -> imagesLoaded は失敗します
- コンソールを開いた状態で上記のアクションを繰り返す場合 -> imagesLoaded が機能する
- 気が向いたらうまくいかないこともあるし…。
ここでの取引は何ですか?これは、Internet Explorer (11、10、9 など) でのみ発生します。
JS は次のとおりです。
function masonryOptions(){
$('.post-wrapper').width((((($('#content').width() - ((columnCount*gutter) - gutter)) / columnCount) / $('#content').width()) * 100)+'%');
$(window).resize(function() {
$('.post-wrapper').width((((($('#content').width() - ((columnCount*gutter) - gutter)) / columnCount) / $('#content').width()) * 100)+'%');
});
container.imagesLoaded(function(){
$('iframe').load(function() {
container.masonry({
itemSelector: '.post-wrapper',
gutter: gutter,
transitionDuration: 0
});
});
});
}
$(document).ready(function(){
masonryOptions();
});