jquery.smallslider.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. /**
  2. * SmallSilder JQuery plugin
  3. * http://lib.kindcent.com/smallslider
  4. * JQuery plugin for switch images, Please Open me with UTF-8 encoding
  5. * Created under Ubuntu 9.10 OS , if you open it with notepad.exe , some black squares will appear !
  6. * 这是一个源码开放程序,本人特意加上注释以方便大家修改,你可以自行修改,再发布,欢迎和我交流。
  7. * 0.5版本新增加actionGap延时选项,部分解决快速滑动时的闪烁问题。
  8. * 即鼠标放上面后,需要等待一段时间才开始切换,默认为200毫秒。
  9. * 不知何年何月才能算1.0版呢?因为我一直觉得切换的过渡效果还没有完全达到我的意志!
  10. *
  11. * Licensed under The MIT License
  12. *
  13. * @version 0.5
  14. * @since 2009-7-3, 11:56:24
  15. * @last 2010-12-6, 01:25:56
  16. * @author Jesse <microji@163.com>
  17. */
  18. /**
  19. * Usage: $('#slider').smallslider({ onImageStop:true, switchEase: 'easeOutSine',switchPath: 'left'});
  20. *
  21. * @param elm 你想要使用的最外层
  22. * @param options 一些附加参数
  23. *
  24. * Valid options:
  25. * ---------------------------------------
  26. * time:3000, // 切换时间间隔,单位毫秒,1秒=1000毫秒
  27. * autoStart:true, // 是否自动开始播放
  28. * onImageStop : false , // 鼠标放在图片上时,是否停止播放
  29. * switchMode:'hover', // 图片切换的方式,click为单击切换,hover为鼠标移动到按钮上时切换
  30. * switchEffect:'fadeOut', // 切换特效,fadeOut, ease, none,
  31. * switchPath: 'left' , // 切换的方向,可选值为:up , left ,即向上,向左
  32. * switchEase : 'easeOutQuart' , // 可选值列表如下
  33. * switchTime: 600, // 切换时间,单位毫秒,1秒=1000毫秒
  34. * actionGap: 200, //[0.5版本新增]鼠标单击或移动触发切换,切换响应的时间间隔,0为立即响应,时间越大,响应越慢
  35. * buttonPosition: 'rightBottom', // 按钮位置表示,共有四个值:leftTop,leftBottom, rightTop, rightBottom
  36. * buttonOffsetX:10, // 水平方向上的按钮偏移位置,指向中心部移动多少,这里是数值,不加px
  37. * buttonOffsetY:4, // 竖直方向上的按钮偏移位置,指向中心部移动多少,这里是数值,不加px
  38. * buttonSpace:4, // 按钮之间的间隔 单位为像素,但不要加px
  39. * showText: true, // 是否显示标题,如果不显示,则只显示按钮
  40. * showButtons : true, // 是否显示按钮,默认显示
  41. * textLink : true, // 是否给显示的标题加上链接,如果为false,则,只显示标题,标题不可单击,链接的地址自动和当前播放到的图片地址一致
  42. * textSwitch : 0 , // 标题是否运动显示,如果为0则不动,1 标题动,2 标题和背景一起动。
  43. * textPosition: '', // 标题栏的位置,默认为空,即和按钮的位置一致,取值 top , bottom
  44. * textAlign: '' // 如果留空,则会默认和按钮位置的相反方向排列,取值:left, center, right
  45. */
  46. (function($) {
  47. $.smallslider=function(elm, options){
  48. // this 为当前的smallslider对象,为了区别,使用 _this 替换
  49. var _this = this;
  50. _this.elm = elm ; // elm 为当前的 DOM对象 ,即使用class="smallslider" 的那个div对象。
  51. _this.$elm = $(elm); // $elm 为elm对象的jquery形式
  52. _this.opts=$.extend({},$.smallslider.defaults, options);
  53. _this.sliderTimer= null ;
  54. _this.actionGapTimer = null;
  55. _this.slideProcessing = false;
  56. // 初始化对象
  57. _this.init = function()
  58. {
  59. _this.$ul = _this.$elm.find('>ul') ; // 为子元素ul
  60. _this.$lis = _this.$elm.find('li') ; // 为所有ul下子元素li 数组
  61. _this.$ims = _this.$elm.find('img') ; // 为所有li下子元素img 数组
  62. _this.itemNums = _this.$lis.length ;
  63. _this.width = _this.$elm.width();
  64. _this.height = _this.$elm.height();
  65. _this.current = 0 ; // 当前的index索引
  66. if(_this.itemNums > 1)
  67. {
  68. if(_this.opts.switchEffect=='ease')
  69. {
  70. _this.$ul.css({
  71. position:'absolute',
  72. left:0,
  73. top: 0
  74. });
  75. if(_this.opts.switchPath=='left')
  76. {
  77. var width = _this.itemNums * _this.width;
  78. _this.$lis.css({
  79. 'float' : 'left'
  80. });
  81. _this.$ul.css({
  82. 'width' : width
  83. });
  84. }
  85. else if(_this.opts.switchPath=='up')
  86. {
  87. var height = _this.itemNums * _this.height;
  88. _this.$ul.css({
  89. 'height' : height
  90. });
  91. }
  92. }
  93. else if(_this.opts.switchEffect=='fadeOut')
  94. {
  95. _this.$ul.css({
  96. position:'relative', width:'100%', height:'100%'
  97. });
  98. _this.$lis.css({
  99. position:'absolute',
  100. zIndex:1
  101. }).eq(0).css({
  102. zIndex:2
  103. });
  104. }
  105. if(_this.opts.showButtons)
  106. {
  107. _this.createButtons(); // 创建按钮。
  108. }
  109. if(_this.opts.showText)
  110. {
  111. _this.createText(); // 创建文字显示。
  112. }
  113. if(_this.opts.autoStart)
  114. {
  115. _this.startSlider(1);
  116. }
  117. if(_this.opts.onImageStop)
  118. {
  119. _this.onImage();
  120. }
  121. }
  122. };
  123. _this.createButtons = function()
  124. {
  125. var buttons='';
  126. for(var i=1; i <= _this.itemNums ; i++ ){
  127. buttons += '<span>'+i+'</span>';
  128. }
  129. buttons ='<div class="smallslider-btns">' + buttons + '</div>';
  130. var left=0,right=0,top =0,bottom=0;
  131. var style_btns={};
  132. switch(_this.opts.buttonPosition){
  133. case 'leftTop':
  134. left = _this.opts.buttonOffsetX;
  135. top = _this.opts.buttonOffsetY;
  136. style_btns={left: left + 'px' , top: top+'px'};
  137. break;
  138. case 'rightTop':
  139. right = _this.opts.buttonOffsetX;
  140. top = _this.opts.buttonOffsetY;
  141. style_btns={right: right + 'px' , top: top+'px'};
  142. break;
  143. case 'rightBottom':
  144. right = _this.opts.buttonOffsetX;
  145. bottom = _this.opts.buttonOffsetY;
  146. style_btns={right: right + 'px' ,bottom: bottom+'px'};
  147. break;
  148. case 'leftBottom':
  149. left = _this.opts.buttonOffsetX;
  150. bottom = _this.opts.buttonOffsetY;
  151. style_btns={left: left + 'px' ,bottom: bottom+'px'};
  152. break;
  153. }
  154. $(buttons).css(style_btns).appendTo(_this.$elm);
  155. _this.$btns = _this.$elm.find('span');
  156. _this.$elm.find('span:not(:first)').css({marginLeft: _this.opts.buttonSpace+'px'});
  157. _this.$btns.removeClass('current-btn');
  158. _this.$btns.eq(0).addClass('current-btn');
  159. if(_this.opts.switchMode=='click'){
  160. _this.$btns.click(function(){
  161. var ix = _this.$btns.index($(this));
  162. //_this.slideTo(ix); // 表示需要切换到哪一张
  163. _this.actionSlide(ix);
  164. });
  165. }else if(_this.opts.switchMode=='hover'){
  166. _this.$btns.hover(function(){
  167. var ix = _this.$btns.index($(this));
  168. //_this.slideTo(ix);
  169. _this.actionSlide(ix);
  170. });
  171. }
  172. };
  173. _this.actionSlide = function(ix){
  174. // console.log(_this.actionGapTimer);
  175. if(_this.actionGapTimer){
  176. clearTimeout(_this.actionGapTimer);
  177. _this.actionGapTimer = null ;
  178. }
  179. _this.actionGapTimer = setTimeout(function(){_this.slideTo(ix) ;}, _this.opts.actionGap);
  180. };
  181. // 创建标题标签
  182. _this.createText = function(){
  183. var style_tex={};
  184. switch(_this.opts.buttonPosition){
  185. case 'leftTop':
  186. style_tex={left:0, top:0,textAlign:'right'};
  187. _this.textPosition = 'top';
  188. break;
  189. case 'rightTop':
  190. style_tex={left:0, top:0,textAlign:'left'};
  191. _this.textPosition = 'top';
  192. break;
  193. case 'rightBottom':
  194. style_tex={left:0,bottom:0,textAlign:'left'};
  195. _this.textPosition = 'bottom';
  196. break;
  197. case 'leftBottom':
  198. style_tex={left:0,bottom:0,textAlign:'right'};
  199. _this.textPosition = 'bottom';
  200. break;
  201. }
  202. if(_this.opts.textPosition){
  203. switch(_this.opts.textPosition)
  204. {
  205. case 'top':
  206. style_tex.left = 0 ;style_tex.top = 0;
  207. break;
  208. case 'bottom':
  209. style_tex.left = 0 ;style_tex.bottom=0 ;
  210. break;
  211. }
  212. _this.textPosition = _this.opts.textPosition ;
  213. }
  214. if(_this.opts.textAlign)
  215. {
  216. style_tex.textAlign =_this.opts.textAlign;
  217. }
  218. $('<div class="smallslider-tex smallslider-lay"></div>').css(style_tex).css({
  219. opacity:0.39
  220. }).appendTo(_this.$elm);
  221. var tex0= _this.$ims.eq(0).attr('alt');
  222. if(_this.opts.textLink){
  223. tex0 = '<a href="'+_this.$ims.eq(0).parent('a').attr('href')+'">'+ tex0+'</a>';
  224. }
  225. $('<h3 class="smallslider-tex"></h3>').css(style_tex).html(tex0).appendTo(_this.$elm);
  226. _this.$h3 = _this.$elm.find('h3');
  227. _this.$lay = _this.$elm.find('div.smallslider-lay');
  228. _this.$tex = _this.$elm.find('.smallslider-tex');
  229. };
  230. _this.onImage =function(){
  231. _this.$ims.hover(function(){
  232. _this.stopSlider();
  233. }, function(){
  234. _this.slideTo(_this.current+1);
  235. });
  236. };
  237. _this.slideTo = function (index){
  238. _this.stopSlider(); // 先清掉以前的setTimeout;
  239. if(index > _this.itemNums -1) index = 0;
  240. if(index < 0 ) index = _this.itemNums -1 ;
  241. // 切换表示当前元素
  242. _this.$lis.removeClass('current-li').eq(index).addClass('current-li');
  243. if(_this.opts.showButtons)
  244. {
  245. _this.$btns.removeClass('current-btn');
  246. _this.$btns.eq(index).addClass('current-btn');
  247. }
  248. _this.slideText(index);
  249. var chAttr = '';
  250. var iC = 0;
  251. switch(_this.opts.switchPath)
  252. {
  253. case 'left':
  254. chAttr = 'left';
  255. iC =_this.width ;
  256. break;
  257. case 'up':
  258. default :
  259. chAttr = 'top';
  260. iC = _this.height ;
  261. break;
  262. }
  263. var iCx = -1 * index * iC; // Top或Left 变化量
  264. var switchEase = _this.opts.switchEase ;
  265. switch( _this.opts.switchEffect){
  266. case 'fadeOut':
  267. if(_this.current != index)
  268. {
  269. _this.slideProcessing = true ;
  270. _this.$lis.stop(true,false);
  271. _this.$lis.css({zIndex:1,opacity:1}).hide();
  272. _this.$lis.eq(_this.current).css({zIndex:3}).show();
  273. _this.$lis.eq(index).css({zIndex:2}).show();
  274. _this.$lis.eq(_this.current).fadeOut(_this.opts.switchTime,function(){
  275. _this.$lis.css({zIndex:1});
  276. _this.$lis.eq(index).css({zIndex:3,opacity:1}).show();
  277. _this.slideProcessing = false;
  278. });
  279. }
  280. break;
  281. case 'ease':
  282. _this.$ul.stop(true,false);
  283. if(chAttr=='top')
  284. _this.$ul.animate({top : iCx}, {duration: _this.opts.switchTime, easing: switchEase, complete: function(){
  285. }
  286. });
  287. else if(chAttr=='left')
  288. _this.$ul.animate({left : iCx}, {duration: _this.opts.switchTime, easing: switchEase ,complete:function(){
  289. }});
  290. break;
  291. case 'none':
  292. default :
  293. _this.$lis.eq(_this.current).hide();
  294. _this.$lis.eq(index).show();
  295. break;
  296. }
  297. _this.current = index ;
  298. _this.startSlider(index+1);
  299. };
  300. // 切换文字
  301. _this.slideText = function(index)
  302. {
  303. if(_this.opts.showText)
  304. {
  305. var tex = _this.$ims.eq(index).attr('alt');
  306. if(_this.opts.textLink){
  307. tex = '<a href="'+_this.$ims.eq(index).parent('a').attr('href')+'">'+ tex+'</a>';
  308. }
  309. _this.$h3.html(tex);
  310. if(_this.opts.textSwitch>0){
  311. var t_path = _this.$h3.height();
  312. var t_ani1 ={}, t_ani2 ={};
  313. if(_this.textPosition=='top'){
  314. t_ani1 = {top : -1*t_path};
  315. t_ani2 = {top : 0};
  316. }
  317. else if(_this.textPosition=='bottom'){
  318. t_ani1 = {bottom : -1*t_path};
  319. t_ani2 = {bottom : 0};
  320. }
  321. if(_this.opts.textSwitch==1) {
  322. _this.$h3.stop(true, false).animate(t_ani1, {duration: 200, easing: 'easeOutQuad'}).animate(t_ani2, {duration: 200, easing: 'easeOutQuad'});
  323. }else if(_this.opts.textSwitch==2){
  324. _this.$tex.stop(true, false).animate(t_ani1, {duration: 200, easing: 'easeOutQuad'}).animate(t_ani2, {duration: 200, easing: 'easeOutQuad'});
  325. //_this.$lay.animate(t_ani1, {duration: 200, easing: 'easeOutQuad'}).animate(t_ani2, {duration: 200, easing: 'easeOutQuad'});
  326. }
  327. }
  328. }
  329. };
  330. // 开始切换
  331. _this.startSlider = function(index){
  332. // 由第几个序号开始 初始为1
  333. var st =setTimeout(function(){
  334. _this.slideTo(index);
  335. },_this.opts.time);
  336. _this.sliderTimer = st ;
  337. };
  338. // 停止切换
  339. _this.stopSlider = function(){
  340. //if(_this.opts.switchEffect=='fadeOut') _this.$lis.stop();
  341. // else if(_this.opts.switchEffect=='ease') _this.$ul.stop();
  342. if(_this.sliderTimer) {
  343. clearTimeout(_this.sliderTimer);
  344. }
  345. _this.sliderTimer = null;
  346. };
  347. _this.init();
  348. };
  349. $.smallslider.defaults={
  350. time:3000,
  351. autoStart:true,
  352. onImageStop : false ,
  353. switchMode:'hover',
  354. switchEffect:'fadeOut',
  355. switchPath: 'left' ,
  356. switchEase : 'easeOutQuart' ,
  357. switchTime: 600,
  358. actionGap: 200,
  359. buttonPosition: 'rightBottom',
  360. buttonOffsetX:10,
  361. buttonOffsetY:4,
  362. buttonSpace:4,
  363. showText: true,
  364. showButtons : true,
  365. textLink : true,
  366. textSwitch : 0 ,
  367. textPosition: '',
  368. textAlign: ''
  369. };
  370. $.fn.smallslider = function(options){
  371. // 遍历由$.smallslider类创建生成的smallslider对象。
  372. return this.each(function(i){
  373. (new $.smallslider(this, options));
  374. });
  375. };
  376. })(jQuery);
  377. $.smallslider.switchEases = ["easeInQuad", "easeOutQuad", "easeInOutQuad", "easeInCubic", "easeOutCubic",
  378. "easeInOutCubic", "easeInQuart", "easeOutQuart", "easeInOutQuart", "easeInQuint", "easeOutQuint", "easeInOutQuint",
  379. "easeInSine", "easeOutSine", "easeInOutSine", "easeInExpo", "easeOutExpo", "easeInOutExpo", "easeInCirc", "easeOutCirc", "easeInOutCirc", "easeInElastic",
  380. "easeOutElastic", "easeInOutElastic", "easeInBack", "easeOutBack", "easeInOutBack",
  381. "easeInBounce", "easeOutBounce", "easeInOutBounce"];
  382. // t: current time, b: begInnIng value, c: change In value, d: duration
  383. jQuery.easing['jswing'] = jQuery.easing['swing'];
  384. jQuery.extend( jQuery.easing,
  385. {
  386. def: 'easeOutQuad',
  387. swing: function (x, t, b, c, d) {
  388. //alert(jQuery.easing.default);
  389. return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
  390. },
  391. easeInQuad: function (x, t, b, c, d) {
  392. return c*(t/=d)*t + b;
  393. },
  394. easeOutQuad: function (x, t, b, c, d) {
  395. return -c *(t/=d)*(t-2) + b;
  396. },
  397. easeInOutQuad: function (x, t, b, c, d) {
  398. if ((t/=d/2) < 1) return c/2*t*t + b;
  399. return -c/2 * ((--t)*(t-2) - 1) + b;
  400. },
  401. easeInCubic: function (x, t, b, c, d) {
  402. return c*(t/=d)*t*t + b;
  403. },
  404. easeOutCubic: function (x, t, b, c, d) {
  405. return c*((t=t/d-1)*t*t + 1) + b;
  406. },
  407. easeInOutCubic: function (x, t, b, c, d) {
  408. if ((t/=d/2) < 1) return c/2*t*t*t + b;
  409. return c/2*((t-=2)*t*t + 2) + b;
  410. },
  411. easeInQuart: function (x, t, b, c, d) {
  412. return c*(t/=d)*t*t*t + b;
  413. },
  414. easeOutQuart: function (x, t, b, c, d) {
  415. return -c * ((t=t/d-1)*t*t*t - 1) + b;
  416. },
  417. easeInOutQuart: function (x, t, b, c, d) {
  418. if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
  419. return -c/2 * ((t-=2)*t*t*t - 2) + b;
  420. },
  421. easeInQuint: function (x, t, b, c, d) {
  422. return c*(t/=d)*t*t*t*t + b;
  423. },
  424. easeOutQuint: function (x, t, b, c, d) {
  425. return c*((t=t/d-1)*t*t*t*t + 1) + b;
  426. },
  427. easeInOutQuint: function (x, t, b, c, d) {
  428. if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  429. return c/2*((t-=2)*t*t*t*t + 2) + b;
  430. },
  431. easeInSine: function (x, t, b, c, d) {
  432. return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  433. },
  434. easeOutSine: function (x, t, b, c, d) {
  435. return c * Math.sin(t/d * (Math.PI/2)) + b;
  436. },
  437. easeInOutSine: function (x, t, b, c, d) {
  438. return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  439. },
  440. easeInExpo: function (x, t, b, c, d) {
  441. return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  442. },
  443. easeOutExpo: function (x, t, b, c, d) {
  444. return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  445. },
  446. easeInOutExpo: function (x, t, b, c, d) {
  447. if (t==0) return b;
  448. if (t==d) return b+c;
  449. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  450. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  451. },
  452. easeInCirc: function (x, t, b, c, d) {
  453. return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  454. },
  455. easeOutCirc: function (x, t, b, c, d) {
  456. return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  457. },
  458. easeInOutCirc: function (x, t, b, c, d) {
  459. if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
  460. return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  461. },
  462. easeInElastic: function (x, t, b, c, d) {
  463. var s=1.70158;var p=0;var a=c;
  464. if (t==0) return b;if ((t/=d)==1) return b+c;if (!p) p=d*.3;
  465. if (a < Math.abs(c)) {a=c;s=p/4;}
  466. else s = p/(2*Math.PI) * Math.asin (c/a);
  467. return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  468. },
  469. easeOutElastic: function (x, t, b, c, d) {
  470. var s=1.70158;var p=0;var a=c;
  471. if (t==0) return b;if ((t/=d)==1) return b+c;if (!p) p=d*.3;
  472. if (a < Math.abs(c)) {a=c;s=p/4;}
  473. else s = p/(2*Math.PI) * Math.asin (c/a);
  474. return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  475. },
  476. easeInOutElastic: function (x, t, b, c, d) {
  477. var s=1.70158;var p=0;var a=c;
  478. if (t==0) return b;if ((t/=d/2)==2) return b+c;if (!p) p=d*(.3*1.5);
  479. if (a < Math.abs(c)) {a=c;s=p/4;}
  480. else s = p/(2*Math.PI) * Math.asin (c/a);
  481. if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  482. return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  483. },
  484. easeInBack: function (x, t, b, c, d, s) {
  485. if (s == undefined) s = 1.70158;
  486. return c*(t/=d)*t*((s+1)*t - s) + b;
  487. },
  488. easeOutBack: function (x, t, b, c, d, s) {
  489. if (s == undefined) s = 1.70158;
  490. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  491. },
  492. easeInOutBack: function (x, t, b, c, d, s) {
  493. if (s == undefined) s = 1.70158;
  494. if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  495. return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  496. },
  497. easeInBounce: function (x, t, b, c, d) {
  498. return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  499. },
  500. easeOutBounce: function (x, t, b, c, d) {
  501. if ((t/=d) < (1/2.75)) {
  502. return c*(7.5625*t*t) + b;
  503. } else if (t < (2/2.75)) {
  504. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  505. } else if (t < (2.5/2.75)) {
  506. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  507. } else {
  508. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  509. }
  510. },
  511. easeInOutBounce: function (x, t, b, c, d) {
  512. if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  513. return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  514. }
  515. });