-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.jcarousel-smoothscroll.min.js
2 lines (2 loc) · 1.19 KB
/
jquery.jcarousel-smoothscroll.min.js
1
2
/*! jcarousel-smoothscroll 1.0.0 | Copyright 2014 Andrew Duthie | MIT License */
!function(a){"use strict";a.jCarousel.plugin("jcarouselSmoothScroll",{_init:function(){this.onDestroy=a.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",a.proxy(this._create,this))},this),this.onAnimate=a.proxy(this._calculate,this)},_create:function(){this.carousel().on("jcarousel:animate",this.onAnimate),this.start()},_destroy:function(){this.carousel().off("jcarousel:destroy",this.onDestroy)},start:function(){var a=this.carousel().data("jcarousel");this.originalAnimation=a.options("animation"),this.maxWidth=this._getItemMaxWidth()},_calculate:function(b,c){var d,c=this.carousel().data("jcarousel"),e=c.target().prev(),f=e.width()/this.maxWidth,g=this._getDurationValue(this.originalAnimation),h=g*f;d="object"==typeof this.originalAnimation?a.extend({},this.originalAnimation,{duration:h}):h,c.options("animation",d)},_getDurationValue:function(b){switch(typeof b){case"string":return a.fx.speeds[b];case"number":return b;case"object":return this._getDurationValue(b.duration);default:return 400}},_getItemMaxWidth:function(){var a=this.carousel().data("jcarousel");return a.items().width()}})}(jQuery);