-
Notifications
You must be signed in to change notification settings - Fork 2
/
jquery.hslides.min.js
8 lines (8 loc) · 2.6 KB
/
jquery.hslides.min.js
1
2
3
4
5
6
7
8
/*
* hSlides (1.0) // 2008.02.25 // <http://www.frontendmatters.com/projects/jquery-plugins/hslides/>
* REQUIRES jQuery 1.2.3+ <http://jquery.com/>
* Copyright (c) 2008 TrafficBroker <http://www.trafficbroker.co.uk>
* Licensed under GPL and MIT licenses
* @author Jesus Carrera <jesus.carrera@frontendmatters.com>
*/
(function(A){A.fn.hSlides=function(B){B=A.extend({},A.fn.hSlides.defaults,B);return this.each(function(){var C=this;var J=0;var F=A(B.panelSelector,C);var D=1;if(B.panelPositioning!="top"){J=(A(B.panelSelector,C).length-1)*B.minPanelWidth;F=A(B.panelSelector,C).reverse();D=-1}A(this).css("position","relative").css("overflow","hidden").css("width",B.totalWidth).css("height",B.totalHeight);var G=0;F.each(function(){A(this).css("position","absolute").css("left",J).css("zIndex",G).css("height",B.totalHeight).css("width",B.maxPanelWidth);G++;if(A(this).hasClass(B.activeClass)){A.data(A(this)[0],"active",true);if(B.panelPositioning!="top"){J=(A(B.panelSelector,C).index(this)+1)*B.minPanelWidth-B.maxPanelWidth}else{J=J+B.maxPanelWidth}}else{if(B.midPanelWidth&&A(B.panelSelector,C).hasClass(B.activeClass)==false){J=J+B.midPanelWidth*D}else{J=J+B.minPanelWidth*D}}});var E=function(){var L=A(B.panelSelector,C).index(this);F.each(function(){if(A.data(A(this)[0],"active")==true){A.data(A(this)[0],"active",false);A(this).removeClass(B.activeClass).each(B.onLeave)}var M=A(B.panelSelector,C).index(this);J=B.minPanelWidth*M;if((M*D)>(L*D)){J=J+(B.maxPanelWidth-B.minPanelWidth)*D}A(this).animate({left:J},B.speed,B.easing)});A.data(A(this)[0],"active",true);A(this).addClass(B.activeClass).each(B.onEnter)};var I=function(){var L=0;if(B.panelPositioning!="top"){L=(A(B.panelSelector,C).length-1)*B.minPanelWidth}F.each(function(){A(this).removeClass(B.activeClass).animate({left:L},B.speed,B.easing);if(A.data(A(this)[0],"active")==true){A.data(A(this)[0],"active",false);A(this).each(B.onLeave)}L=L+B.midPanelWidth*D})};if(B.eventHandler=="click"){A(B.panelSelector,C).click(E)}else{var H={sensitivity:B.sensitivity,interval:B.interval,over:E,timeout:B.timeout,out:function(){}};var K={sensitivity:B.sensitivity,interval:B.interval,over:function(){},timeout:B.timeout,out:I};A(B.panelSelector,C).hoverIntent(H);if(B.midPanelWidth!=0){A(C).hoverIntent(K)}}})};A.fn.reverse=function(){return this.pushStack(this.get().reverse(),arguments)};A.fn.hSlides.defaults={totalWidth:0,totalHeight:0,minPanelWidth:0,maxPanelWidth:0,midPanelWidth:0,speed:1000,easing:"swing",sensitivity:3,interval:200,timeout:300,eventHandler:"click",panelSelector:"li",activeClass:false,panelPositioning:"top",onEnter:function(){},onLeave:function(){}}})(jQuery);