zoukankan      html  css  js  c++  java
  • 无缝滚动插件

    ;(function($){
    $.fn.moveUp=function(options){
    var defaults = {//初始化参数
    moveHeight:22,
    time:2000
    };
    var opts =$.extend({},defaults,options);//扩展参数

    var a=$(this);
    var top=0;
    var timer;
    a.find('li').first().clone().appendTo(a);//克隆追加第一个子对象
    timer=setInterval(moveUp,opts.time);
    a.hover(function(){clearInterval(timer)},function(){timer=setInterval(moveUp,opts.time)});
    var endHeight=a.height();//追加子对象后的总高度
    function moveUp(){
    top=top+opts.moveHeight;
    if(top>=endHeight){
    a.css('marginTop','0px');
    top=opts.moveHeight;
    }
    a.stop().animate({'marginTop':-top+'px'});
    //document.title=a.css('marginTop');
    }
    };
    $.fn.moveLeft=function(options){
    var defaults = {//初始化参数
    moveWidth:100,
    time:2000
    };
    var opts =$.extend({},defaults,options);//扩展参数

    var a=$(this);
    var left=0;
    var timer;
    a.find('li').first().clone().appendTo(a);//克隆追加第一个子对象
    timer=setInterval(moveLeft,opts.time);
    a.hover(function(){clearInterval(timer)},function(){timer=setInterval(moveLeft,opts.time)});
    var endWidth=a.width();//追加子对象后的总高度
    function moveLeft(){
    left=left+opts.moveWidth;
    if(left>=endWidth){
    a.css('marginLeft','0px');
    left=opts.moveWidth;
    }
    a.stop().animate({'marginLeft':-left+'px'});
    //document.title=a.css('marginTop');
    }
    }
    })(jQuery);
    $(function(){
    $('.demo ul').moveUp({moveHeight:22,time:2200});
    $('.demo2 ul').moveLeft({moveWidth:100,time:2200});
    })

  • 相关阅读:
    alg--动态规划(dynamic planning)
    alg--分治法
    汇编-理解call,ret
    汇编--实验7
    leetCode笔记--binary tree
    leetCode笔记--(1)
    C#获取当前路径的方法如下
    VS2013 快捷键 与 RESHARPER 冲突
    使用Visual Studio 2013进行单元测试--初级篇
    VS 插件
  • 原文地址:https://www.cnblogs.com/binmengxue/p/7805444.html
Copyright © 2011-2022 走看看