0

Hey Ive は、クリックで画像をフルスクリーン表示するための fancybox のような jquery プラグインに取り組んでいます。

私が抱えている問題は、プラグインをさまざまな要素で複数回呼び出して、そこに独自の定義済みの設定を与えることができるようにしたいということです。

以下のように、各IDには独自のfadeIn時間があります

-> ("#id1").fadeIn(200);

-> ("#id2").fadeIn(400);

これを完全に機能させたいので、これを行う方法は何ですか:D

画像ボックスの例を使用して要素をセットアップします。

// Two jQuery Calls with different settings.
$('.smallImage img').imageBox({
    'transition' : 'fadeIn',
    'cursor' : 'pointer',
    'gallery' : 'on'
});

$('.bigImage img').imageBox({
    'transition' : 'fadeIn',
    'cursor' : 'pointer',
    'gallery' : 'off'
});

(function( $ ){
    // Grab plugin settings sent from call - took from jquery developers area.
    $.fn.imageBox = function( method ) {  
        if ( methods[method] ) {
          return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
        } else if ( typeof method === 'object' || ! method ) {
          return methods.init.apply( this, arguments ); // Sends settings through here.
        } else {
          $.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' );
        }    
    };

    var settings;
    var methods = {
        init : function( options ) { 
            settings = $.extend({
                'transition' : "fadeIn",
                'cursor' : 'pointer',
                'gallery' : 'on'
            }, options);
        }
    }
})( jQuery );

アイデアは大歓迎です、ありがとう。

4

0 に答える 0