// Tween算法
  var Tween = {
    // t:当前步数
    // b:初始位置
    // c:总距离
    // d:总步数
    // Linear:匀速
  Linear: function(t,b,c,d){ return c*t/d + b; },
    // 平方缓动动画
    Quad: {
      // 加速
      easeIn: function(t,b,c,d){
        return c*(t/=d)*t + b;
      },
      // 减速
      easeOut: function(t,b,c,d){
        return -c *(t/=d)*(t-2) + b;
      },
      // 现加速后减速
      easeInOut: function(t,b,c,d){
        if ((t/=d/2) < 1) return c/2*t*t + b;
        return -c/2 * ((--t)*(t-2) - 1) + b;
      }
    },
  // 三次方缓动动画
  Cubic: {
    easeIn: function(t,b,c,d){
      return c*(t/=d)*t*t + b;
    },
    easeOut: function(t,b,c,d){
      return c*((t=t/d-1)*t*t + 1) + b;
    },
    easeInOut: function(t,b,c,d){
      if ((t/=d/2) < 1) return c/2*t*t*t + b;
      return c/2*((t-=2)*t*t + 2) + b;
    }
  },
  // 四次方缓动动画
  Quart: {
    easeIn: function(t,b,c,d){
      return c*(t/=d)*t*t*t + b;
    },
    easeOut: function(t,b,c,d){
      return -c * ((t=t/d-1)*t*t*t - 1) + b;
    },
    easeInOut: function(t,b,c,d){
      if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
      return -c/2 * ((t-=2)*t*t*t - 2) + b;
    }
  },
  // 五次方缓动动画
  Quint: {
    easeIn: function(t,b,c,d){
      return c*(t/=d)*t*t*t*t + b;
    },
    easeOut: function(t,b,c,d){
      return c*((t=t/d-1)*t*t*t*t + 1) + b;
    },
    easeInOut: function(t,b,c,d){
      if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
      return c/2*((t-=2)*t*t*t*t + 2) + b;
    }
  },
  // 正弦缓动动画
  Sine: {
    easeIn: function(t,b,c,d){
      return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
    },
    easeOut: function(t,b,c,d){
      return c * Math.sin(t/d * (Math.PI/2)) + b;
    },
    easeInOut: function(t,b,c,d){
      return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
    }
  },
  // 指数缓动动画
  Expo: {
    easeIn: function(t,b,c,d){
      return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
    },
    easeOut: function(t,b,c,d){
      return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
    },
    easeInOut: function(t,b,c,d){
      if (t==0) return b;
      if (t==d) return b+c;
      if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
      return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
    }
   },
  // 圆形缓动动画
  Circ: {
      easeIn: function(t,b,c,d){
        return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
      },
      easeOut: function(t,b,c,d){
        return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
      },
      easeInOut: function(t,b,c,d){
        if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
        return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
      }
    },
  // 指数衰减
  Elastic: {
    easeIn: function(t,b,c,d,a,p){
      if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
      if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
      else var s = p/(2*Math.PI) * Math.asin (c/a);
      return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
    },
    easeOut: function(t,b,c,d,a,p){
      if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
      if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
      else var s = p/(2*Math.PI) * Math.asin (c/a);
      return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
    },
    easeInOut: function(t,b,c,d,a,p){
    if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
    if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
    else var s = p/(2*Math.PI) * Math.asin (c/a);
    if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
    return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
    }
  },
  // 超出范围的三次方缓动动画
  Back: {
    easeIn: function(t,b,c,d,s){
      if (s == undefined) s = 1.70158;
      return c*(t/=d)*t*((s+1)*t - s) + b;
    },
    easeOut: function(t,b,c,d,s){
      if (s == undefined) s = 1.70158;
      return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
    },
    easeInOut: function(t,b,c,d,s){
      if (s == undefined) s = 1.70158;
      if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
      return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
    }
  },
  // 反弹
  Bounce: {
    easeIn: function(t,b,c,d){
      return c - Tween.Bounce.easeOut(d-t, 0, c, d) + b;
    },
    easeOut: function(t,b,c,d){
      if ((t/=d) < (1/2.75)) {
      return c*(7.5625*t*t) + b;
      } else if (t < (2/2.75)) {
      return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
      } else if (t < (2.5/2.75)) {
      return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
      } else {
      return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
      }
    },
      easeInOut: function(t,b,c,d){
        if (t < d/2) return Tween.Bounce.easeIn(t*2, 0, c, d) * .5 + b;
        else return Tween.Bounce.easeOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
      }
    }
  };

js轮播插件的更多相关文章

  1. js 轮播插件

    flexslider pc插件 个人用过 flickerplate 移动端插件 个人用过 个人觉得比较好的移动端插件 swiper  http://www.swiper.com.cn/  用过 个人觉 ...

  2. 原生JS实现"旋转木马"效果的图片轮播插件

    一.写在最前面 最近都忙一些杂七杂八的事情,复习软考.研读经典...好像都好久没写过博客了... 我自己写过三个图片轮播,一个是简单的原生JS实现的,没有什么动画效果的,一个是结合JQuery实现的, ...

  3. 纯js写图片轮播插件

    最近终于写成了自己创作的图片轮播插件,使用原生js编写.与目前网上流行的轮播插件相比,功能和效果稍弱,但是使用起来相当方便. 先看html代码 <!DOCTYPE html> <ht ...

  4. 推荐:图片轮播插件Nivo Slider

          因为项目需要一款切换样式多一些的轮播插件,不经意找到了NivoSlider,非常好用,比bootstrap要好用,而且样式丰富.值得注意的是,这款插件是在MIT协议下免费的.        ...

  5. PgwSlideshow-基于Jquery的图片轮播插件

    0 PgwSlideshow简介 PgwSlideshow是一款基于Jquery的图片轮播插件,基本布局分为上下结构,上方为大图轮播区域,用户可自定义图片轮播切换的间隔时间,也可以通过单击左右方向按键 ...

  6. js-自制轮播插件!

    刚接触轮播的时候,感觉这种东西好高端,后来学习了jquery后,发现原来挺简单的,而且实现轮播也有很多形式,我用jquery自制了一个轮播插件,其实我这个说是插件,好像其实就是一个高度抽象的函数而已. ...

  7. owl-carousel轮播插件的使用

    插件github地址:https://github.com/OwlFonk/OwlCarousel: 插件官网演示地址:http://owlgraphic.com/owlcarousel/: 1.选择 ...

  8. 图片轮播插件-carouFredSel

    carouFredSel图片轮播插件基于Jquery,比较常规的轮播插件,支持滚轮及键盘左右按键,加入其它插件可实现更加复杂的特效. 主页地址:http://caroufredsel.dev7stud ...

  9. JQuery插件之图片轮播插件–slideBox

    来源:http://www.ido321.com/852.html 今天偶然发现了一个比较好用的图片轮播插件—slideBox 先看看效果:http://slidebox.sinaapp.com/ 代 ...

随机推荐

  1. Alpha阶段敏捷冲刺---Day3

    一.Daily Scrum Meeting照片 二.今天冲刺情况反馈 今天我们上完课后在禹洲楼教室外进行我们的每日立会.开会的内容主要是总结了一下这几天各自的任务及任务进度,交流了一下各自遇到的困难. ...

  2. grep命令与正则表达式

    搜寻特定字符串the 常用参数:-a 将binary档案以test档案的方式搜寻数据    -c  计算找到'搜寻字符串'的次数    -i 忽略大小写的不同  -n  顺便输出行号  -v  反向选 ...

  3. select 从应用层到内核实现解析

    在一个应用中,如果需要读取多个设备文件,这其中有多种实现方式: 1.使用一个进程,并采用同步查询机制,不停的去轮询每一个设备描述符,当设备描述符不可用时,进程睡眠. 2:使用多个进程或者线程分别读取一 ...

  4. Ubuntu 16.04 LTS安装 cuda8.0

    参考文献: http://blog.csdn.net/autocyz/article/details/52299889 http://blog.csdn.net/lixintong1992/artic ...

  5. Web Components 是什么

    /********************************************************************************* * Web Components ...

  6. C语言 位移 速度 时间 Demo

    /************************************************************************* * C语言(s = v*t + a*t*t/2)D ...

  7. Sql语句中两个比较迷糊的概念:“连接查询” 与 “外键约束”

    Sql语句中两个比较迷糊的概念:“连接查询” 与 “外键约束 Sql 中的连接查询:就是为了避免笛卡尔积,因为涉及到多表查询的化,不使用连接查询,会先将多个互相乘,求出笛卡尔积,然后在在里面查询符合的 ...

  8. 《DSP using MATLAB》Problem 4.17

  9. java1.8操作日期

    java1.8获取年份: int year = Calendar.getInstance().get(Calendar.YEAR); StringBuilder code = new StringBu ...

  10. 基于TLS(线程局部存储)的高效timelog实现

    什么是timelog? 我们在分析程序性能的时候,会加入的一些logging信息记录每一部分的时间信息 timelog模块的功能就是提供统一的接口来允许添加和保存logging 我们正在用的timel ...