/* * chriswang * 396276123@qq.com * 2014.11.28 * github:https://github.com/powy1993/fullpage */ function fullpage(k){function a(a,g,f,c){this.cx=3*a;this.bx=3*(f-a)-this.cx;this.ax=1-this.cx-this.bx;this.cy=3*g;this.by=3*(c-g)-this.cy;this.ay=1-this.cy-this.by}var b=document.getelementbyid(k.id),e=b.children,h=e.length,v=h,c=k.slidetime||800,w=k.effect||{},b=0,y,d,h,m,s,e,o,p,q,f=[],r=[],s,u,t=null,t=!1,i=!1,w,l,z,g,v,x,y,q,x,l,u;if(e&&1!==h){k.mode&&(i=-1!==k.mode.indexof("nav:"),r=k.mode.split(","),s=r.length);for(l=0;lc;c++){b=this.samplecurvex(d)-a;if(math.abs(b)c)return c;for(;fb?f=d:c=d;d=.5*(c-f)+f}return d},solve:function(a,g){return this.samplecurvey(this.solvecurvex(a, g))}};g=function(){m=document.documentelement.clientwidth||window.innerwidth;s=document.documentelement.clientheight||window.innerheight;b.style.height=s+"px"};l=function(a,g,f,b){e=a;o=g;p=f;q=b};if("string"===typeof k.easing)switch(k.easing){case "ease":l(.25,.1,.25,1);break;case "linear":l(0,0,1,1);break;case "ease-in":l(.42,0,1,1);break;case "ease-out":l(0,0,.58,1);break;case "ease-in-out":l(.42,0,.58,1)}else l(k.easing[0],k.easing[1],k.easing[2],k.easing[3]);if(""!==h){for(;v--;)f[v][h+"transitiontimingfunction"]= "cubic-bezier("+e+","+o+","+p+","+q+")";v=function(a,g,f,b,d){a=a.style;g="translate("+g+"px,"+f+"px) translatez(0)";d.scale&&(g+=0===b?" scale("+d.scale[0]+")":" scale("+d.scale[1]+")");d.rotate&&(g+=0===b?" rotate("+d.rotate[0]+"deg)":" rotate("+d.rotate[1]+"deg)");a[h+"transformorigin"]="50% 50%";a[h+"transform"]=g}}else w=new a(e,o,p,q),v=function(a,g,b,c){var d=a.currentstyle,e=a.style,h=parseint(e.left||d.left,10),k=parseint(e.top||d.top,10),q=g-h,l=b-k,s=+new date+c,m=0,r=w.opacity,t;clearinterval(t); t=setinterval(function(){var a;+new date>s?(a=r?"left:"+g+"px;top:"+b+"px;filter:alpha(opacity="+100*r[1]+");":"left:"+g+"px;top:"+b+"px;",clearinterval(t)):(t=s-new date,m=t/c,m=w.solve(1-m,a.prototype.epsilon),a="left:"+(h+q*m)+"px;top:"+(k+l*m)+"px;",r&&(a+="filter:alpha(opacity="+100*(r[1]*m-r[0]*(1-m))+");"));e.csstext=a},13)};x={transform:function(a,g,b){var c=0,d=""!==h||"none"!==a.translate&&a.translate?z:-50;switch(a.translate){case "y":c=b>g?s:-s;v(e[b],0,c,0,a);break;case "x":c=b>g?m:-m; v(e[b],c,0,0,a);break;case "xy":c={x:b>g?m:-m,y:b>g?s:-s};v(e[b],c.x,c.y,0,a);break;default:v(e[b],0,0,0,a)}settimeout(function(){v(e[b],0,0,c,a)},d+50)},opacity:function(a,b,f){var c=e[f].style;c.opacity=a[0];settimeout(function(){c.opacity=a[1]},70)}};y=y&&d?navigator.useragent.indexof("firefox")?function(a,b){a.addeventlistener("click",b,!1)}:function(a,b,f){a.addeventlistener("touchstart",b,!1);f&&a.addeventlistener("touchmove",function(a){a.preventdefault()},!1)}:function(a,b){a.onclick=b};q= function(a,b,f){var c=a.classname,d=[];if(-1!==c.indexof(b)){d=c.split(" ");for(c=d.length;c--;)d[c]===b&&(" "===f||""===f?d.splice(c,1):d[c]=f);d.length?a.classname=d.join(" "):(a.removeattribute("class"),a.removeattribute("classname"))}};i&&(l=function(a,b){var f=u[b].classname;q(u[a],"active"," ");u[b].classname=""===f?"active":f+" active"});x=function(a){var g=z,f,c;if(!(t||a===b||a>=h||0>a)){t=!0;for(c in w)x[c](w[c],b,a);g+=""===h?20:0;f=b;b=a;i&&l(f,b);settimeout(function(){e[a].classname+= " slide"},g);settimeout(function(){f[a][h+"transitionduration"]=c+"ms"},20);settimeout(function(){q(e[f],"current","");q(e[b],"slide","current");k.callback&&k.callback(b,e[b]);t=!1},c+z+120)}};g();l=e[b].classname;e[b].classname=-1!==l.indexof("current")?l:l+" current";for(y?window.addeventlistener("resize",g,!1):window.onresize=g;s--;)(function(a){switch(!0){case "wheel"===a:u=function(a){a=a||window.event;a.preventdefault?a.preventdefault():a.returnvalue=!1;t||(a=-a.wheeldelta||a.detail,x(b+(0> a?-1:1)))};y&&document.addeventlistener("dommousescroll",u,!1);window.onmousewheel=document.onmousewheel=u;break;case "touch"===a:if(!d||!y)break;(function(){var a=w.transform.scale[0],f=w.transform.scale[1]-a,c=w.transform.rotate[0],d=w.transform.rotate[1]-c,l=w.opacity[0],u=w.opacity[1]-l,v,x,y,z,g,r={},a=!1,n,p,d,m,n,e,j;"y"===w.transform.translate?(d=function(){n=f[b-1];p=f[b+1];n&&(n[h+"transitionduration"]="0ms",n[h+"transform"]="translate(0,-"+s+"px) translatez(0)",n[h+"transformorigin"]="50% 100%", e[b-1].classname+=" swipe");p&&(p[h+"transitionduration"]="0ms",p[h+"transform"]="translate(0,"+s+"px) translatez(0)",p[h+"transformorigin"]="50% 0%",e[b+1].classname+=" swipe")},e=function(b){var e=math.abs(b.y/s),k=" scale("+(a+f*e)+") rotate("+(c+d*e)+"deg)";n&&0b.y&&(p.opacity=l+u*e,p[h+"transform"]="translate(0,"+(s+b.y)+"px) translatez(0)"+k)},m=function(a,d){var c=c>>1;q(e[b+d],"swipe","slide");a.opacity= 1;a[h+"transitionduration"]=c+"ms";a[h+"transform"]="translate(0,"+d*s+"px) translatez(0)";settimeout(function(){q(e[b+d],"slide","");settimeout(function(){t=!1},50)},c)},n=function(a,d){var c=b+d,f=~~(c/1.5),g=e[b-d];g&&q(g,"swipe","");0>c||c>h-1?settimeout(function(){t=!1},50):(i&&l(b,c),a.opacity=1,q(e[c],"swipe","slide"),a[h+"transitionduration"]=f+"ms",a[h+"transform"]="translate(0,0) translatez(0)",settimeout(function(){q(e[b],"current","");q(e[c],"slide","current");b=c;k.callback&&k.callback(b, e[b]);settimeout(function(){t=!1},50)},f))}):(d=function(){n=f[b-1];p=f[b+1];n&&(n[h+"transitionduration"]="0ms",n[h+"transform"]="translate(-"+m+"px,0) translatez(0)",n[h+"transformorigin"]="100% 50%",e[b-1].classname+=" swipe");p&&(p[h+"transitionduration"]="0ms",p[h+"transform"]="translate("+m+"px,0) translatez(0)",p[h+"transformorigin"]="0 50%",e[b+1].classname+=" swipe")},e=function(b){var e=math.abs(b.x/m),k=" scale("+(a+f*e)+") rotate("+(c+d*e)+"deg)";n&&0b.x&&(p.opacity=l+u*e,p[h+"transform"]="translate("+(m+b.x)+"px,0) translatez(0)"+k)},m=function(a,c){var d=c>>1;q(e[b+c],"swipe","slide");a.opacity=1;a[h+"transitionduration"]=d+"ms";a[h+"transform"]="translate("+c*m+"px,0) translatez(0)";settimeout(function(){q(e[b+c],"slide","");settimeout(function(){t=!1},50)},d)},n=function(a,c){var d=b+c,f=~~(c/1.5),g=e[b-c];g&&q(g,"swipe","");0>d||d>h-1?settimeout(function(){t=!1},50):(i&& l(b,d),q(e[d],"swipe","slide"),a.opacity=1,a[h+"transitionduration"]=f+"ms",a[h+"transform"]="translate(0,0) translatez(0)",settimeout(function(){q(e[b],"current","");q(e[d],"slide","current");b=d;k.callback&&k.callback(b,e[b]);settimeout(function(){t=!1},50)},f))});v=function(a){var b=a.touches[0];a.preventdefault();1math.abs(r.y)?"x":"y",j=j===k.effect.transform.translate?!0:!1,a=!0))};x= function(a){var b=a.changedtouches[0];a=+new date-g;var d;d=0;var c=!1;r={x:b.pagex-y,y:b.pagey-z};b=math.abs(r.x);d=math.abs(r.y);switch(k.effect.transform.translate){case "y":c=250>+a&&30.3*s;d=0+a&&30.3*m;d=0+a&&50.3*s||b>.3*m,d=b>d?0