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});
    })

  • 相关阅读:
    python学习第三 天-字典
    购物车
    python学习第二天-字符串
    python学习第二天-元组
    git 工作流中的 Sourcetree 和命令行操作对比
    服务端推送通信技术及其优劣势
    关于立即调用的函数表达式(IIFE)
    序列化和反序列化
    mac 使用 brew 安装 nginx 及各种命令
    前端安全问题之CSRF和XSS
  • 原文地址:https://www.cnblogs.com/binmengxue/p/7805444.html
Copyright © 2011-2022 走看看