0

jCarousel Liteを初期化するときに、リストの最初の要素に「class="active"」状態を追加できるようにしたい。プラグインを変更せずにこれにどのようにアプローチしますか?

現在の設定-

$('#viewport').jCarouselLite({
    speed: 500,
    visible: 3,
    scroll: 1,
    start: 0, // Just for testing purposes
    circular: true,
    btnNext: '#next',
    btnPrev: '#previous',
    beforeStart: function(a) {
        $(a[0]).animate({opacity: .5}, 250).toggleClass('active');
    },
    afterEnd: function(a) {
        $(a[0]).animate({opacity: 1}, 500).toggleClass('active');
    }
});
4

3 に答える 3

1

jCarouselLiteの初期化直後、

以下をせよ

$('#viewport ul li:first').addClass('active');
于 2012-04-05T13:59:25.313 に答える
0

軌道に乗っていない場合は、事前にお詫び申し上げます。jCarouselLiteの初期化の前にこのクラスを追加することはできませんか?

コメントタグの間にあるコードをjCarouselソースに追加します。

div.css(sizeCss, divSize+"px");                     // Width of the DIV. length of visible images

/* add this */

    if(o.atStart){
        o.atStart.call(this, vis());
    }else{
        //not set
    }

/**/

    if(o.btnPrev)
        $(o.btnPrev).click(function() {
            return go(curr-o.scroll);
        });

次に、jCarousel初期化に追加のパラメーターを渡します。

$('#viewport').jCarouselLite({
    speed: 500,
    visible: 3,
    scroll: 1,
    start: 0, // Just for testing purposes
    circular: true,
    btnNext: '#next',
    btnPrev: '#previous',
    beforeStart: function(a) {
        $(a[0]).animate({opacity: .5}, 250).toggleClass('active');
    },
    afterEnd: function(a) {
        $(a[0]).animate({opacity: 1}, 500).toggleClass('active');
    },
    atStart: function(a){
        //do your stuff
    }
});
于 2012-04-05T13:11:36.570 に答える
0
beforeStart: function(a) { 
     $(a[0]).toggleClass('active').siblings().removeClass('active');

}

//この小さなスクリプトだけで終了

于 2017-12-07T14:18:39.073 に答える