forked from alvarotrigo/fullPage.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.fullPage.min.js
1 lines (1 loc) · 16.6 KB
/
jquery.fullPage.min.js
1
(function(a){a.fn.fullpage=function(E){E=a.extend({hashChange:false,initialSlide:0,verticalCentered:true,resize:true,slidesColor:[],anchors:[],scrollingSpeed:700,easing:"easeInQuart",menu:false,navigation:false,navigationPosition:"right",navigationColor:"#000",navigationTooltips:[],slidesNavigation:false,slidesNavPosition:"bottom",controlArrowColor:"#fff",loopBottom:false,loopTop:false,loopHorizontal:true,autoScrolling:true,scrollOverflow:false,css3:false,paddingTop:0,paddingBottom:0,fixedElements:null,normalScrollElements:null,keyboardScrolling:true,touchSensitivity:5,continuousVertical:false,animateAnchor:true,afterLoad:null,onLeave:null,afterRender:null,afterSlideLoad:null,onSlideLeave:null},E);if(E.continuousVertical&&(E.loopTop||E.loopBottom)){E.continuousVertical=false;console&&console.log&&console.log("Option loopTop/loopBottom is mutually exclusive with continuousVertical; continuousVertical disabled")}var z=600;a.fn.fullpage.setAutoScrolling=function(V){E.autoScrolling=V;var U=a(".section.active");if(E.autoScrolling){a("html, body").css({overflow:"hidden",height:"100%"});if(U.length){B(U.position().top)}}else{a("html, body").css({overflow:"auto",height:"auto"});B(0);a("html, body").scrollTop(U.position().top)}};a.fn.fullpage.setScrollingSpeed=function(U){E.scrollingSpeed=U};a.fn.fullpage.setMouseWheelScrolling=function(U){if(U){I()}else{p()}};a.fn.fullpage.setAllowScrolling=function(U){if(U){a.fn.fullpage.setMouseWheelScrolling(true);n()}else{a.fn.fullpage.setMouseWheelScrolling(false);R()}};a.fn.fullpage.setKeyboardScrolling=function(U){E.keyboardScrolling=U};var g=false;var P=navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|Windows Phone)/);var m=a(window).height();var i=false;var b=false;var j;var M;a.fn.fullpage.setAllowScrolling(true);if(E.css3){E.css3=G()}a("body").wrapInner('<div id="superContainer" />');if(E.navigation){a("body").append('<div id="fullPage-nav"><ul></ul></div>');var r=a("#fullPage-nav");r.css("color",E.navigationColor);r.addClass(E.navigationPosition)}a(".section").each(function(U){var W=a(this).find(".slide");var V=W.length;if(U==E.initialSlide){a(this).addClass("active")}a(this).css("height",m+"px");if(E.paddingTop||E.paddingBottom){a(this).css("padding",E.paddingTop+" 0 "+E.paddingBottom+" 0")}if(typeof E.slidesColor[U]!=="undefined"){a(this).css("background-color",E.slidesColor[U])}if(typeof E.anchors[U]!=="undefined"){a(this).attr("data-anchor",E.anchors[U])}if(E.navigation){var Y="";if(E.anchors.length){Y=E.anchors[U]}var Z=E.navigationTooltips[U];if(typeof Z==="undefined"){Z=""}r.find("ul").append('<li data-tooltip="'+Z+'"><a href="#'+Y+'"><span></span></a></li>')}if(V>0){var X=V*100;var aa=100/V;W.wrapAll('<div class="slidesContainer" />');W.parent().wrap('<div class="slides" />');a(this).find(".slidesContainer").css("width",X+"%");a(this).find(".slides").after('<div class="controlArrow prev"></div><div class="controlArrow next"></div>');if(E.controlArrowColor!="#fff"){a(this).find(".controlArrow.next").css("border-color","transparent transparent transparent "+E.controlArrowColor);a(this).find(".controlArrow.prev").css("border-color","transparent "+E.controlArrowColor+" transparent transparent")}if(!E.loopHorizontal){a(this).find(".controlArrow.prev").hide()}if(E.slidesNavigation){x(a(this),V)}W.each(function(ab){if(!ab){a(this).addClass("active")}a(this).css("width",aa+"%");if(E.verticalCentered){w(a(this))}})}else{if(E.verticalCentered){w(a(this))}}}).promise().done(function(){a.fn.fullpage.setAutoScrolling(E.autoScrolling);a.isFunction(E.afterRender)&&E.afterRender.call(this);if(E.fixedElements&&E.css3){a(E.fixedElements).appendTo("body")}if(E.navigation){r.css("margin-top","-"+(r.height()/2)+"px");r.find("li").first().find("a").addClass("active")}if(E.menu&&E.css3){a(E.menu).appendTo("body")}if(E.scrollOverflow){a(window).on("load",function(){a(".section").each(function(){var X=a(this).find(".slide");if(X.length){X.each(function(){L(a(this))})}else{L(a(this))}})})}if(E.hashChange){var V=window.location.hash.replace("#","").split("/");var U=V[0];if(U.length){var W=a('[data-anchor="'+U+'"]');if(!E.animateAnchor&&W.length){B(W.position().top);W.addClass("active").siblings().removeClass("active")}}a(window).on("load",function(){e()})}});var K;var c=false;a(window).scroll(function(X){if(!E.autoScrolling){var U=a(window).scrollTop();var W=a(".section").map(function(){if(a(this).offset().top<(U+100)){return a(this)}});var Y=W[W.length-1];if(!Y.hasClass("active")){c=true;var Z=J(Y);a(".section.active").removeClass("active");Y.addClass("active");var V=Y.data("anchor");a.isFunction(E.onLeave)&&E.onLeave.call(this,Y.index(".section"),Z);a.isFunction(E.afterLoad)&&E.afterLoad.call(this,V,(Y.index(".section")+1));h(V);s(V,0);if(E.anchors.length&&!i&&E.hashChange){j=V;location.hash=V}clearTimeout(K);K=setTimeout(function(){c=false},100)}}});var C=0;var D=0;var d=0;var f=0;function F(W){if(E.autoScrolling){W.preventDefault();var Y=W.originalEvent;var Z=false;var U=a(".section.active");var X;if(!i&&!g){var V=t(Y);d=V.y;f=V.x;if(U.find(".slides").length&&Math.abs(D-f)>(Math.abs(C-d))){if(Math.abs(D-f)>(a(window).width()/100*E.touchSensitivity)){if(D>f){U.find(".controlArrow.next:visible").trigger("click")}else{U.find(".controlArrow.prev:visible").trigger("click")}}}else{if(U.find(".slides").length){X=U.find(".slide.active").find(".scrollable")}else{X=U.find(".scrollable")}if(Math.abs(C-d)>(a(window).height()/100*E.touchSensitivity)){if(C>d){if(X.length>0){if(O("bottom",X)){a.fn.fullpage.moveSectionDown()}else{return true}}else{a.fn.fullpage.moveSectionDown()}}else{if(d>C){if(X.length>0){if(O("top",X)){a.fn.fullpage.moveSectionUp()}else{return true}}else{a.fn.fullpage.moveSectionUp()}}}}}}}}function A(V){if(E.autoScrolling){var W=V.originalEvent;var U=t(W);C=U.y;D=U.x}}function Q(W){if(E.autoScrolling){W=window.event||W;var X=Math.max(-1,Math.min(1,(W.wheelDelta||-W.detail)));var V;var U=a(".section.active");if(!i){if(U.find(".slides").length){V=U.find(".slide.active").find(".scrollable")}else{V=U.find(".scrollable")}if(X<0){if(V.length>0){if(O("bottom",V)){a.fn.fullpage.moveSectionDown()}else{return true}}else{a.fn.fullpage.moveSectionDown()}}else{if(V.length>0){if(O("top",V)){a.fn.fullpage.moveSectionUp()}else{return true}}else{a.fn.fullpage.moveSectionUp()}}}return false}}a.fn.fullpage.moveSectionUp=function(){var U=a(".section.active").prev(".section");if(!U.length&&(E.loopTop||E.continuousVertical)){U=a(".section").last()}if(U.length){u(U,null,true)}};a.fn.fullpage.moveSectionDown=function(){var U=a(".section.active").next(".section");if(!U.length&&(E.loopBottom||E.continuousVertical)){U=a(".section").first()}if(U.length>0||(!U.length&&(E.loopBottom||E.continuousVertical))){u(U,null,false)}};a.fn.fullpage.moveTo=function(W,U){var V="";if(isNaN(W)){V=a('[data-anchor="'+W+'"]')}else{V=a(".section").eq((W-1))}if(U!=="undefined"){S(W,U)}else{if(V.length>0){u(V)}}};function u(U,X,W){var aa={},Y;var ab=U.position();if(typeof ab==="undefined"){return}var ae=ab.top;var ai=J(U);var Z=U.data("anchor");var ah=U.index(".section");var ac=U.find(".slide.active");var al=a(".section.active");if(ac.length){var ag=ac.data("anchor");var aj=ac.index()}if(E.autoScrolling&&E.continuousVertical&&typeof(W)!=="undefined"&&((!W&&ai=="up")||(W&&ai=="down"))){if(!W){a(".section.active").after(al.prevAll(".section").get().reverse())}else{a(".section.active").before(al.nextAll(".section"))}B(a(".section.active").position().top);var ad=al;ab=U.position();ae=ab.top;ai=J(U)}var V=al.index(".section")+1;U.addClass("active").siblings().removeClass("active");i=true;if(typeof Z!=="undefined"){v(aj,ag,Z)}if(E.autoScrolling){aa.top=-ae;Y="#superContainer"}else{aa.scrollTop=ae;Y="html, body"}var af=function(){if(!ad||!ad.length){return}if(W){a(".section:first").before(ad)}else{a(".section:last").after(ad)}B(a(".section.active").position().top)};if(E.css3&&E.autoScrolling){a.isFunction(E.onLeave)&&E.onLeave.call(this,V,ai);var ak="translate3d(0px, -"+ae+"px, 0px)";N(ak,true);setTimeout(function(){af();a.isFunction(E.afterLoad)&&E.afterLoad.call(this,Z,(ah+1));setTimeout(function(){i=false;a.isFunction(X)&&X.call(this)},z)},E.scrollingSpeed)}else{a.isFunction(E.onLeave)&&E.onLeave.call(this,V,ai);a(Y).animate(aa,E.scrollingSpeed,E.easing,function(){af();a.isFunction(E.afterLoad)&&E.afterLoad.call(this,Z,(ah+1));setTimeout(function(){i=false;a.isFunction(X)&&X.call(this)},z)})}j=Z;if(E.autoScrolling){h(Z);s(Z,ah)}}function e(){var V=window.location.hash.replace("#","").split("/");var W=V[0];var U=V[1];if(W){S(W,U)}}if(E.hashChange){a(window).on("hashchange",function(){if(!c){var W=window.location.hash.replace("#","").split("/");var Y=W[0];var U=W[1];var X=(typeof j==="undefined");var V=(typeof j==="undefined"&&typeof U==="undefined");if((Y&&Y!==j)&&!X||V||(!g&&M!=U)){S(Y,U)}}})}a(document).keydown(function(U){if(E.keyboardScrolling&&!i){switch(U.which){case 38:case 33:a.fn.fullpage.moveSectionUp();break;case 40:case 34:a.fn.fullpage.moveSectionDown();break;case 37:a(".section.active").find(".controlArrow.prev:visible").trigger("click");break;case 39:a(".section.active").find(".controlArrow.next:visible").trigger("click");break;default:return}}});a(document).on("click","#fullPage-nav a",function(V){V.preventDefault();var U=a(this).parent().index();u(a(".section").eq(U))});a(document).on({mouseenter:function(){var U=a(this).data("tooltip");a('<div class="fullPage-tooltip '+E.navigationPosition+'">'+U+"</div>").hide().appendTo(a(this)).fadeIn(200)},mouseleave:function(){a(this).find(".fullPage-tooltip").fadeOut().remove()}},"#fullPage-nav li");if(E.normalScrollElements){a(document).on("mouseover",E.normalScrollElements,function(){a.fn.fullpage.setMouseWheelScrolling(false)});a(document).on("mouseout",E.normalScrollElements,function(){a.fn.fullpage.setMouseWheelScrolling(true)})}a(".section").on("click",".controlArrow",function(){if(g){return}g=true;var V=a(this).closest(".section").find(".slides");var W=V.find(".slide.active");var U=null;if(a(this).hasClass("prev")){U=W.prev(".slide")}else{U=W.next(".slide")}if(!U.length){if(a(this).hasClass("prev")){U=W.siblings(":last")}else{U=W.siblings(":first")}}l(V,U)});a(".section").on("click",".toSlide",function(W){W.preventDefault();var V=a(this).closest(".section").find(".slides");var X=V.find(".slide.active");var U=null;U=V.find(".slide").eq((a(this).data("index")-1));if(U.length>0){l(V,U)}});function l(V,Y){var ah=Y.position();var U=V.find(".slidesContainer").parent();var ad=Y.index();var ag=V.closest(".section");var ae=ag.index(".section");var aa=ag.data("anchor");var Z=ag.find(".fullPage-slidesNav");var W=Y.data("anchor");var ab=b;if(E.onSlideLeave){var X=ag.find(".slide.active").index();var af=k(X,ad);if(!ab){a.isFunction(E.onSlideLeave)&&E.onSlideLeave.call(this,aa,(ae+1),X,af)}}Y.addClass("active").siblings().removeClass("active");if(typeof W==="undefined"){W=ad}if(ag.hasClass("active")){if(!E.loopHorizontal){ag.find(".controlArrow.prev").toggle(ad!=0);ag.find(".controlArrow.next").toggle(!Y.is(":last-child"))}v(ad,W,aa)}if(E.css3){var ac="translate3d(-"+ah.left+"px, 0px, 0px)";V.find(".slidesContainer").addClass("easing").css({"-webkit-transform":ac,"-moz-transform":ac,"-ms-transform":ac,transform:ac});setTimeout(function(){if(!ab){a.isFunction(E.afterSlideLoad)&&E.afterSlideLoad.call(this,aa,(ae+1),W,ad)}g=false},E.scrollingSpeed,E.easing)}else{U.animate({scrollLeft:ah.left},E.scrollingSpeed,E.easing,function(){if(!ab){a.isFunction(E.afterSlideLoad)&&E.afterSlideLoad.call(this,aa,(ae+1),W,ad)}g=false})}Z.find(".active").removeClass("active");Z.find("li").eq(ad).find("a").addClass("active")}if(!P){var q;a(window).resize(function(){clearTimeout(q);q=setTimeout(y,500)})}a(window).bind("orientationchange",function(){y()});function y(){b=true;var W=a(window).width();m=a(window).height();if(E.resize){T(m,W)}a(".section").each(function(){var Y=m-parseInt(a(this).css("padding-bottom"))-parseInt(a(this).css("padding-top"));if(E.scrollOverflow){var X=a(this).find(".slide");if(X.length){X.each(function(){L(a(this))})}else{L(a(this))}}if(E.verticalCentered){a(this).find(".tableCell").css("height",o(a(this))+"px")}a(this).css("height",m+"px");var X=a(this).find(".slides");if(X.length){l(X,X.find(".slide.active"))}});var V=a(".section.active").position();var U=a(".section.active");if(U.index(".section")){u(U)}b=false}function T(Z,W){var Y=825;var X=Z;if(Z<825||W<900){if(W<900){X=W;Y=900}var V=(X*100)/Y;var U=V.toFixed(2);a("body").css("font-size",U+"%")}else{a("body").css("font-size","100%")}}function s(U,V){if(E.navigation){a("#fullPage-nav").find(".active").removeClass("active");if(U){a("#fullPage-nav").find('a[href="#'+U+'"]').addClass("active")}else{a("#fullPage-nav").find("li").eq(V).find("a").addClass("active")}}}function h(U){if(E.menu){a(E.menu).find(".active").removeClass("active");a(E.menu).find('[data-menuanchor="'+U+'"]').addClass("active")}}function O(U,V){if(U==="top"){return !V.scrollTop()}else{if(U==="bottom"){return V.scrollTop()+V.innerHeight()>=V[0].scrollHeight}}}function J(V){var U=a(".section.active").index(".section");var W=V.index(".section");if(U>W){return"up"}return"down"}function k(U,V){if(U>V){return"left"}return"right"}function L(U){U.css("overflow","hidden");var Y=U.closest(".section");var X=U.find(".scrollable");if(X.length){var W=U.find(".scrollable").get(0).scrollHeight}else{var W=U.get(0).scrollHeight;if(E.verticalCentered){W=U.find(".tableCell").get(0).scrollHeight}}var V=m-parseInt(Y.css("padding-bottom"))-parseInt(Y.css("padding-top"));if(W>V){if(X.length){X.css("height",V+"px").parent().css("height",V+"px")}else{if(E.verticalCentered){U.find(".tableCell").wrapInner('<div class="scrollable" />')}else{U.wrapInner('<div class="scrollable" />')}U.find(".scrollable").slimScroll({height:V+"px",size:"10px",alwaysVisible:true})}}else{U.find(".scrollable").children().first().unwrap().unwrap();U.find(".slimScrollBar").remove();U.find(".slimScrollRail").remove()}U.css("overflow","")}function w(U){U.addClass("table").wrapInner('<div class="tableCell" style="height:'+o(U)+'px;" />')}function o(V){var W=m;if(E.paddingTop||E.paddingBottom){var X=V;if(!X.hasClass("section")){X=V.closest(".section")}var U=parseInt(X.css("padding-top"))+parseInt(X.css("padding-bottom"));W=(m-U)}return W}function N(U,V){a("#superContainer").toggleClass("easing",V);a("#superContainer").css({"-webkit-transform":U,"-moz-transform":U,"-ms-transform":U,transform:U})}function S(V,U){if(typeof U==="undefined"){U=0}if(isNaN(V)){var W=a('[data-anchor="'+V+'"]')}else{var W=a(".section").eq((V-1))}if(V!==j&&!W.hasClass("active")){u(W,function(){H(W,U)})}else{H(W,U)}}function H(X,U){if(typeof U!="undefined"){var W=X.find(".slides");var V=W.find('[data-anchor="'+U+'"]');if(!V.length){V=W.find(".slide").eq(U)}if(V.length){l(W,V)}}}function x(W,V){W.append('<div class="fullPage-slidesNav"><ul></ul></div>');var X=W.find(".fullPage-slidesNav");X.addClass(E.slidesNavPosition);for(var U=0;U<V;U++){X.find("ul").append('<li><a href="#"><span></span></a></li>')}X.css("margin-left","-"+(X.width()/2)+"px");X.find("li").first().find("a").addClass("active")}function v(W,X,U){var V="";if(E.anchors.length&&E.hashChange){if(W){if(typeof U!=="undefined"){V=U}if(typeof X==="undefined"){X=W}M=X;location.hash=V+"/"+X}else{if(typeof W!=="undefined"){M=X;location.hash=U}else{location.hash=U}}}}a(document).on("click",".fullPage-slidesNav a",function(W){W.preventDefault();var V=a(this).closest(".section").find(".slides");var U=V.find(".slide").eq(a(this).closest("li").index());l(V,U)});function G(){var W=document.createElement("p"),X,V={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(W,null);for(var U in V){if(W.style[U]!==undefined){W.style[U]="translate3d(1px,1px,1px)";X=window.getComputedStyle(W).getPropertyValue(V[U])}}document.body.removeChild(W);return(X!==undefined&&X.length>0&&X!=="none")}function p(){if(document.addEventListener){document.removeEventListener("mousewheel",Q,false);document.removeEventListener("DOMMouseScroll",Q,false)}else{document.detachEvent("onmousewheel",Q)}}function I(){if(document.addEventListener){document.addEventListener("mousewheel",Q,false);document.addEventListener("DOMMouseScroll",Q,false)}else{document.attachEvent("onmousewheel",Q)}}function n(){if(P){a(document).off("touchstart MSPointerDown").on("touchstart MSPointerDown",A);a(document).off("touchmove MSPointerMove").on("touchmove MSPointerMove",F)}}function R(){if(P){a(document).off("touchstart MSPointerDown");a(document).off("touchmove MSPointerMove")}}function t(V){var U=new Array();if(window.navigator.msPointerEnabled){U.y=V.pageY;U.x=V.pageX}else{U.y=V.touches[0].pageY;U.x=V.touches[0].pageX}return U}function B(V){if(E.css3){var U="translate3d(0px, -"+V+"px, 0px)";N(U,false)}else{a("#superContainer").css("top",-V)}}}})(jQuery);