1

私はhttp://isotope.metafizzy.co/docs/options.html#onlayoutを使用していますが、次のように表示されます。

「コールバックと同様に、onLayoutは、Isotopeインスタンスがそのレイアウトロジックを実行するたびにトリガーされる関数です。」

$('#container').isotope({
   onLayout: function( $elems ) {
    // `this` refers to jQuery object of the container element
    console.log( this.height() );
    // callback provides jQuery object of laid-out item elements
    $elems.css({ background: 'blue' });
    }
});

つまり、「レイアウト」が終了したら、これを実行できます。

 $elems.css({ background: 'blue' });

私は「$elems」を持っていませんが、「onLayout」が終了すると、必要なものを実行できることを理解できます。これを実行したいと思います。

$("#container").width(); 
$("#head").animate({ width: newWidth}, "fast");

しかし、「()」内の「$ elems」はどのように、そして何ですか?

ありがとう

4

1 に答える 1

1

次のような要素にカスタムイベントをバインドできます。

$('#container').bind('my_event', function ()
{
    alert('my_event has just fired!');
});

そしてそれを次のように呼びます.trigger()

$('#container').trigger('my_event');

これを使えば、かなり簡単に設定できるはずだと思います。


アップデート:

このコードを呼び出す代わりに:

$('#container').isotope({
   onLayout: function( $elems ) {
    // `this` refers to jQuery object of the container element
    console.log( this.height() );
    // callback provides jQuery object of laid-out item elements
    $elems.css({ background: 'blue' });
    }
});

これを呼んでください:

$('#container').isotope({
   onLayout: function( $elems ) {
        // `this` refers to jQuery object of the container element
        console.log( this.height() );
        // callback provides jQuery object of laid-out item elements
        $elems.css({ background: 'blue' });
        $("#container").width(); 
        $("#head").animate({ width: newWidth}, "fast");
    }
});
于 2012-02-11T01:22:23.953 に答える