문자 윤파

1791 단어
(function($){
    $.fn.myScroll = function(options){
    // 
    var defaults = {
        speed:40,  // , ( )
        rowHeight:24 // 
    };
    
    var opts = $.extend({}, defaults, options);
    var intId = [];
    
    function marquee(obj, liHeight){
    
        obj.find("ul").animate({
            marginTop: '-=1'
        },0,function(){
                var ulMargintop = Math.abs(parseInt($(this).css("margin-top")));
            // $(this) ul 
                if(ulMargintop >= liHeight){
                    $(this).find("li").slice(0, 1).appendTo($(this));
                    // li ul 
                    //(appendTo : , , )
                    $(this).css("margin-top", 0);
                }
            });
        }
        // this ul 
        this.each(function(i){
            var liHeight = opts["rowHeight"];
            var speed = opts["speed"];
            var _this = $(this);// this ul 
            console.log(i);
            intId[i] = setInterval(function(){
                if(_this.find("ul").height()<=_this.height()){
                    clearInterval(intId[i]);
                }else{
                    marquee(_this, liHeight);
                }
            }, speed);

            // hover , 
            _this.hover(function(){
                clearInterval(intId[i]);
            },function(){
                intId[i] = setInterval(function(){
                    if(_this.find("ul").height()<=_this.height()){
                        clearInterval(intId[i]);
                    }else{
                        marquee(_this, liHeight);
                    }
                }, speed);
            });
        
        });

    }

})(jQuery);

좋은 웹페이지 즐겨찾기