table列表滚动

css 

index.html 





简单的jQuery无缝向上滚动效果演示1_dowebok 



   


  
     
        
        
        
        
     
  
  
     
        
        
        
        
     
     
        
        
        
        
     
     
        
        
        
        
     
     
        
        
        
        
     
     
        
        
        
        
     
     
        
        
        
        
     
     
        
        
        
        
     
     
        
        
        
        
     
     
        
        
        
        
     
     
        
        
        
        
     
     
        
        
        
        
     
     
        
        
        
        
     

  


序号姓名公司省会
1bert云智慧河南
2bert云智慧河南
3bert云智慧河南
4bert云智慧河南
5bert云智慧河南
6bert云智慧河南
7bert云智慧河南
8bert云智慧河南
9bert云智慧河南
10bert云智慧河南
11bert云智慧河南
12bert云智慧河南

   

 

scroll.js

(function($){
    $.fn.myScroll = function(options){
        //默认配置
        var defaults = {
            speed:40,  //滚动速度,值越大速度越慢
            rowHeight:30 //每行的高度
        };

        var opts = $.extend({}, defaults, options),intId = [];

        function marquee(obj, step){

            obj.find("table").animate({
                marginTop: '-=1'
            },10,function(){
                var s = Math.abs(parseInt($(this).css("margin-top")));
                if((s-30) >= step){ //减去 table thead的高度
                    $(this).find("tbody tr").slice(0, 1).appendTo($(this));
                    $(this).css("margin-top", '-30px');
                }
            });
        }

        this.each(function(i){
            var sh = opts["rowHeight"],speed = opts["speed"],_this = $(this);
            intId[i] = setInterval(function(){
                if(_this.find("table").height()<=_this.height()){
                    clearInterval(intId[i]);
                }else{
                    marquee(_this, sh);
                }
            }, speed);

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

        });

    }

})(jQuery);

 

 

 

你可能感兴趣的:(table列表滚动)