私はIsotope pluginをWordpressページのグリッドに使用しています。 IsotopeのimagesLoaded
オプションを使用して、ページが読み込まれたときにページ上のイメージが重ならないようにしたいと考えています。誰かが私の既存のコードでどこでどのように使用しなければならないと私に説明することができますimagesLoaded
?Isotope Plugin:imagesLoadedオプションの使い方は?
jQuery(function ($) {
var $container = $('#isotope-list');
$container.isotope({
itemSelector : '.item',
layoutMode : 'masonry',
percentPosition: true
});
//Add the class selected to the item that is clicked, and remove from the others
var $optionSets = $('#filters'),
$optionLinks = $optionSets.find('a');
$optionLinks.click(function(){
var $this = $(this);
// don't proceed if already selected
if ($this.hasClass('selected')) {
return false;
}
var $optionSet = $this.parents('#filters');
$optionSets.find('.selected').removeClass('selected');
$this.addClass('selected');
//When an item is clicked, sort the items.
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
return false;
});
});
UPDATE:
私はimagesLoadedを追加しようとしたが、それは完全に動作を停止する同位体のプラグインが発生します。ここでimagesLoadedとのコードを追加します:
jQuery(function ($) {
var $container = $('#isotope-list').imagesLoaded(function() {
$container.isotope({
itemSelector : '.item',
layoutMode : 'masonry',
percentPosition: true
});
});
//Add the class selected to the item that is clicked, and remove from the others
var $optionSets = $('#filters'),
$optionLinks = $optionSets.find('a');
$optionLinks.click(function(){
var $this = $(this);
// don't proceed if already selected
if ($this.hasClass('selected')) {
return false;
}
var $optionSet = $this.parents('#filters');
$optionSets.find('.selected').removeClass('selected');
$this.addClass('selected');
//When an item is clicked, sort the items.
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
return false;
});
});
私はページのヘッダーにimagesLoadedスクリプトにリンクしていますが、Chromeでページを検査するとき、私は、次のエラーを取得しています:
ここまで追加してみましたか?アイソトープを初期化する前または後に呼び出すことができます。それであなたは問題を引き起こしましたか? – FluffyKitten
[docs](https://isotope.metafizzy.co/layout.html#imagesloaded)を読んでいれば、その方法を知ることができます。編集可能なデモなども付属しています。 – Terry
[IsotopeはimagesLoadedで動作しません]の複製がありますか?(https://stackoverflow.com/questions/23387010/isotope-not-working-with-imagesloaded) – Terry