-
Notifications
You must be signed in to change notification settings - Fork 4
/
jquery.bounceslider.min.js
7 lines (7 loc) · 2.88 KB
/
jquery.bounceslider.min.js
1
2
3
4
5
6
7
/*! http://bounceslider.design4mobile.eu by @ograbek */
(function(a){a.fn.bounceSlider=function(n){var d=a.extend({maxWidth:"",bottomButtonsAsNumbers:!1,auto:!1,timeout:5E3,bottomNavigation:!0,nextPrevNavigation:!0,pauseOnHover:!0},n),g="ontouchend"in document?"touchend":"mouseup";return this.each(function(){var c=a(this),k=a("li",c),e=k.eq(0),l=k.length,r=l-1;slidesShortcut=[];d.nextPrevNavigation||a(".bounce-nav").hide();for(var s="",f=1;f<=l;f++)s=1==f?"gradient active":"gradient",k.eq(f-1).css({"z-index":l-f}).attr("data-slide-number",f),slidesShortcut.push('<li data-goto-slide="'+
f+'" class="'+s+'">'+f+"</li>");d.bottomNavigation&&(l=d.bottomButtonsAsNumbers?"bounce-bottom-buttons numbers":"bounce-bottom-buttons",a("<ol/>").addClass(l).append(slidesShortcut.join("")).appendTo(c));d.maxWidth&&c.css({"max-width":d.maxWidth});var t=function(){769>a(window).width()?a(".bounce-desc",c).addClass("rectangle"):a(".bounce-desc",c).removeClass("rectangle")};t();var n=function(){var b=a(".bounce-desc",e);Modernizr.cssanimations?(b.hasClass("left-side")&&b.addClass("bounce-to-left"),
b.hasClass("right-side")&&b.addClass("bounce-to-right")):b.animate({opacity:0},600)},v=function(b){b.removeClass("bounce-to-left bounce-to-right bounce-from-left bounce-from-right")},p=function(b,h){v(h.add(a(".bounce-desc",e)));h.css({opacity:0});a("> ul > li",c).not(e).css({"z-index":0});b.css({"z-index":r-1});n();e.animate({opacity:0},800,function(){h.hasClass("left-side")&&h.addClass("bounce-from-left");h.hasClass("right-side")&&h.addClass("bounce-from-right");e.css({"z-index":0,opacity:100});
b.css({"z-index":r});e=b;var d=e.attr("data-slide-number");a(".bounce-bottom-buttons li",c).removeClass("active");a('.bounce-bottom-buttons li[data-goto-slide="'+d+'"]',c).addClass("active")})};if(d.auto)var q=setInterval(function(){a(".bounce-nav.next",c).trigger(g)},d.timeout);var m=function(){d.auto&&(clearInterval(q),q=setInterval(function(){a(".bounce-nav.next",c).trigger(g)},d.timeout))};d.pauseOnHover&&(a("> ul",c).bind("mouseover",function(){clearInterval(q)}),a("> ul",c).bind("mouseout",
function(){m()}));a(".bounce-nav.next",c).bind(g,function(){var b=0<e.next().length?e.next():k.eq(0);p(b,a(".bounce-desc",b));m()});a(".bounce-nav.prev",c).bind(g,function(){var b=0<e.prev().length?e.prev():k.last();p(b,a(".bounce-desc",b));m()});a(".bounce-bottom-buttons li",c).bind(g,function(){var b=a('ul li[data-slide-number="'+a(this).attr("data-goto-slide")+'"]',c);b.is(e)||p(b,a(".bounce-desc",b));m()});a(window).resize(function(){t()});var u;a("> ul",c).bind({"touchstart mousedown":function(b){b.preventDefault();
var a=b.originalEvent;u=(a.targetTouches?a.targetTouches[0]:b).pageX},"touchend mouseup":function(b){var d=b.originalEvent;b=(d.changedTouches?d.changedTouches[0]:b).pageX-u;30<Math.abs(b)&&(0<b?a(".bounce-nav.prev",c).trigger(g):a(".bounce-nav.next",c).trigger(g))},touchmove:function(a){a.preventDefault()}})})}})(jQuery);