0

スタックを作成したいのですが、スタックごとにdivコンテナーがあります。そのコンテナには、スタックのアイテムである多くのdivがあります。

'クラス'を使用したい(javascriptには実際にはクラスがないことを知っています)。

まず、コンテナを取得し、ここから渡します。

var stacks = [];

$(document).ready(function(){

    $('.stackContainer').each(function(containerIndex) {
        //stacks[containerIndex] = $(this);
        $(this).css('z-index', containerIndex);
        stacks.push(new StackMedia($(this)));
    });

});

今、難しい部分が来ます(私にとって)。StackMediaでは、アイテムを保存したいのですが、これはstackItemクラスを持つ単なるdivです(シングルトンになるべきではありません)。

私はたくさんのことを試しました、私が得るatmは可変アイテムを見つけることができません。

function StackMedia (container) { //, x, y, overlapX, overlapY
    this.container = container;
    //this.x = x;
    //this.y = y;
    //this.overlapX = overlapX;
    //this.overlapY = overlapY;

    this.items = container.find('.stackItem');
    console.log(items.length);

    //var elems = container.find('.stackItem'); 
    //var $items = jQuery.makeArray(elems);

    /*
    for(var i = 0; i < $items.length; i++) {
        console.log($items[i]);
        $items[i].css('top', i * 10).css('left', i * 10);

    }
    */

    /*
    this.items = [];

    container.find('.stackItem').each(function(itemIndex) {
        //console.log($(this));
        //items = $(this);
        this.items.push("test");
    });
    */

    /*
    items = container.find('.stackItem');
    */



}

どうすれば私が望むものを達成できますか?

4

0 に答える 0