forked from ajgagnon/fullPage.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.fullPage.min.js
44 lines (44 loc) · 18.5 KB
/
jquery.fullPage.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* fullPage 2.3.7
* https://github.com/alvarotrigo/fullPage.js
* MIT licensed
*
* Copyright (C) 2013 alvarotrigo.com - A project by Alvaro Trigo
*/
(function(a){a.fn.fullpage=function(b){function ha(){a("body").append('<div id="fp-nav"><ul></ul></div>');m=a("#fp-nav");m.css("color",b.navigationColor);m.addClass(b.navigationPosition);for(var c=0;c<a(".fp-section").length;c++){var d="";b.anchors.length&&(d=b.anchors[c]);var e=b.navigationTooltips[c];"undefined"===typeof e&&(e="");m.find("ul").append('<li data-tooltip="'+e+'"><a href="#'+d+'"><span></span></a></li>')}}function M(){a(".fp-section").each(function(){var c=a(this).find(".fp-slide");
c.length?c.each(function(){y(a(this))}):y(a(this))});a.isFunction(b.afterRender)&&b.afterRender.call(this)}function N(){if(!b.autoScrolling){var c=a(window).scrollTop(),d=0,e=Math.abs(c-a(".fp-section").first().offset().top);a(".fp-section").each(function(b){var f=Math.abs(c-a(this).offset().top);f<e&&(d=b,e=f)});var f=a(".fp-section").eq(d);if(!f.hasClass("active")){E=!0;var g=a(".fp-section.active").index(".fp-section")+1,n=F(f),k=f.data("anchor");f.addClass("active").siblings().removeClass("active");
p||(a.isFunction(b.onLeave)&&b.onLeave.call(this,g,f.index(".fp-section")+1,n),a.isFunction(b.afterLoad)&&b.afterLoad.call(this,k,f.index(".fp-section")+1));G(k);H(k,0);b.anchors.length&&!p&&(w=k,location.hash=k);clearTimeout(O);O=setTimeout(function(){E=!1},100)}b.fitSection&&(clearTimeout(P),P=setTimeout(function(){p||q(f)},1E3))}}function Q(c){return scrollable=c.find(".fp-slides").length?c.find(".fp-slide.active").find(".fp-scrollable"):c.find(".fp-scrollable")}function z(c,b){if("down"==c)var e=
"bottom",f=a.fn.fullpage.moveSectionDown;else e="top",f=a.fn.fullpage.moveSectionUp;if(0<b.length)if(e="top"===e?!b.scrollTop():"bottom"===e?b.scrollTop()+1+b.innerHeight()>=b[0].scrollHeight:void 0,e)f();else return!0;else f()}function ia(c){var d=c.originalEvent;if(!R(c.target)){b.autoScrolling&&c.preventDefault();c=a(".fp-section.active");var e=Q(c);p||t||(d=S(d),l=d.y,A=d.x,c.find(".fp-slides").length&&Math.abs(B-A)>Math.abs(s-l)?Math.abs(B-A)>a(window).width()/100*b.touchSensitivity&&(B>A?a.fn.fullpage.moveSlideRight():
a.fn.fullpage.moveSlideLeft()):b.autoScrolling&&Math.abs(s-l)>a(window).height()/100*b.touchSensitivity&&(s>l?z("down",e):l>s&&z("up",e)))}}function R(c,d){d=d||0;var e=a(c).parent();return d<b.normalScrollElementTouchThreshold&&e.is(b.normalScrollElements)?!0:d==b.normalScrollElementTouchThreshold?!1:R(e,++d)}function ja(c){c=S(c.originalEvent);s=c.y;B=c.x}function u(c){if(b.autoScrolling){c=window.event||c;c=Math.max(-1,Math.min(1,c.wheelDelta||-c.deltaY||-c.detail));var d=a(".fp-section.active"),
d=Q(d);p||(0>c?z("down",d):z("up",d));return!1}}function T(c){var d=a(".fp-section.active").find(".fp-slides");if(d.length&&!t){var e=d.find(".fp-slide.active"),f=null,f="prev"===c?e.prev(".fp-slide"):e.next(".fp-slide");if(!f.length){if(!b.loopHorizontal)return;f="prev"===c?e.siblings(":last"):e.siblings(":first")}t=!0;x(d,f)}}function U(){a(".fp-slide.active").each(function(){I(a(this))})}function q(c,d,e){var f={},g=c.position();if("undefined"!==typeof g){var g=g.top,n=F(c),k=c.data("anchor"),
h=c.index(".fp-section"),m=c.find(".fp-slide.active"),C=a(".fp-section.active"),q=C.index(".fp-section")+1,r=D;if(m.length)var t=m.data("anchor"),u=m.index();if(b.autoScrolling&&b.continuousVertical&&"undefined"!==typeof e&&(!e&&"up"==n||e&&"down"==n)){e?a(".fp-section.active").before(C.nextAll(".fp-section")):a(".fp-section.active").after(C.prevAll(".fp-section").get().reverse());v(a(".fp-section.active").position().top);U();var l=C,g=c.position(),g=g.top,n=F(c)}c.addClass("active").siblings().removeClass("active");
p=!0;"undefined"!==typeof k&&V(u,t,k);b.autoScrolling?(f.top=-g,c="."+W):(f.scrollTop=g,c="html, body");var s=function(){l&&l.length&&(e?a(".fp-section:first").before(l):a(".fp-section:last").after(l),v(a(".fp-section.active").position().top),U());a.isFunction(b.afterLoad)&&!r&&b.afterLoad.call(this,k,h+1);setTimeout(function(){p=!1;a.isFunction(d)&&d.call(this)},600)};a.isFunction(b.onLeave)&&!r&&b.onLeave.call(this,q,h+1,n);b.css3&&b.autoScrolling?(X("translate3d(0px, -"+g+"px, 0px)",!0),setTimeout(function(){s()},
b.scrollingSpeed)):a(c).animate(f,b.scrollingSpeed,b.easing).promise().done(function(){s()});w=k;b.autoScrolling&&(G(k),H(k,h))}}function Y(){if(!E){var c=window.location.hash.replace("#","").split("/"),a=c[0],c=c[1];if(a.length){var b="undefined"===typeof w,f="undefined"===typeof w&&"undefined"===typeof c&&!t;(a&&a!==w&&!b||f||!t&&J!=c)&&K(a,c)}}}function x(c,d){var e=d.position(),f=c.find(".fp-slidesContainer").parent(),g=d.index(),n=c.closest(".fp-section"),k=n.index(".fp-section"),h=n.data("anchor"),
m=n.find(".fp-slidesNav"),l=d.data("anchor"),r=D;if(b.onSlideLeave){var p=n.find(".fp-slide.active").index(),q;q=p==g?"none":p>g?"left":"right";r||"none"===q||a.isFunction(b.onSlideLeave)&&b.onSlideLeave.call(this,h,k+1,p,q)}d.addClass("active").siblings().removeClass("active");"undefined"===typeof l&&(l=g);b.loopHorizontal||(n.find(".fp-controlArrow.fp-prev").toggle(0!=g),n.find(".fp-controlArrow.fp-next").toggle(!d.is(":last-child")));n.hasClass("active")&&V(g,l,h);var s=function(){r||a.isFunction(b.afterSlideLoad)&&
b.afterSlideLoad.call(this,h,k+1,l,g);t=!1};b.css3?(e="translate3d(-"+e.left+"px, 0px, 0px)",c.find(".fp-slidesContainer").toggleClass("fp-easing",0<b.scrollingSpeed).css(Z(e)),setTimeout(function(){s()},b.scrollingSpeed,b.easing)):f.animate({scrollLeft:e.left},b.scrollingSpeed,b.easing,function(){s()});m.find(".active").removeClass("active");m.find("li").eq(g).find("a").addClass("active")}function $(){L?"text"!==a(document.activeElement).attr("type")&&a.fn.fullpage.reBuild(!0):(clearTimeout(aa),
aa=setTimeout(function(){a.fn.fullpage.reBuild(!0)},500))}function ka(c,b){if(825>c||900>b){var e=Math.min(100*c/825,100*b/900).toFixed(2);a("body").css("font-size",e+"%")}else a("body").css("font-size","100%")}function H(c,d){b.navigation&&(a("#fp-nav").find(".active").removeClass("active"),c?a("#fp-nav").find('a[href="#'+c+'"]').addClass("active"):a("#fp-nav").find("li").eq(d).find("a").addClass("active"))}function G(c){b.menu&&(a(b.menu).find(".active").removeClass("active"),a(b.menu).find('[data-menuanchor="'+
c+'"]').addClass("active"))}function F(c){var b=a(".fp-section.active").index(".fp-section");c=c.index(".fp-section");return b>c?"up":"down"}function y(c){c.css("overflow","hidden");var a=c.closest(".fp-section"),e=c.find(".fp-scrollable");if(e.length)var f=e.get(0).scrollHeight;else f=c.get(0).scrollHeight,b.verticalCentered&&(f=c.find(".fp-tableCell").get(0).scrollHeight);a=r-parseInt(a.css("padding-bottom"))-parseInt(a.css("padding-top"));f>a?e.length?e.css("height",a+"px").parent().css("height",
a+"px"):(b.verticalCentered?c.find(".fp-tableCell").wrapInner('<div class="fp-scrollable" />'):c.wrapInner('<div class="fp-scrollable" />'),c.find(".fp-scrollable").slimScroll({allowPageScroll:!0,height:a+"px",size:"10px",alwaysVisible:!0})):ba(c);c.css("overflow","")}function ba(a){a.find(".fp-scrollable").children().first().unwrap().unwrap();a.find(".slimScrollBar").remove();a.find(".slimScrollRail").remove()}function ca(a){a.addClass("fp-table").wrapInner('<div class="fp-tableCell" style="height:'+
da(a)+'px;" />')}function da(a){var d=r;if(b.paddingTop||b.paddingBottom)d=a,d.hasClass("fp-section")||(d=a.closest(".fp-section")),a=parseInt(d.css("padding-top"))+parseInt(d.css("padding-bottom")),d=r-a;return d}function X(a,b){h.toggleClass("fp-easing",b);h.css(Z(a))}function K(c,b){"undefined"===typeof b&&(b=0);var e=isNaN(c)?a('[data-anchor="'+c+'"]'):a(".fp-section").eq(c-1);c===w||e.hasClass("active")?ea(e,b):q(e,function(){ea(e,b)})}function ea(a,b){if("undefined"!=typeof b){var e=a.find(".fp-slides"),
f=e.find('[data-anchor="'+b+'"]');f.length||(f=e.find(".fp-slide").eq(b));f.length&&x(e,f)}}function la(a,d){a.append('<div class="fp-slidesNav"><ul></ul></div>');var e=a.find(".fp-slidesNav");e.addClass(b.slidesNavPosition);for(var f=0;f<d;f++)e.find("ul").append('<li><a href="#"><span></span></a></li>');e.css("margin-left","-"+e.width()/2+"px");e.find("li").first().find("a").addClass("active")}function V(a,d,e){var f="";b.anchors.length&&(a?("undefined"!==typeof e&&(f=e),"undefined"===typeof d&&
(d=a),J=d,location.hash=f+"/"+d):("undefined"!==typeof a&&(J=d),location.hash=e))}function ma(){var a=document.createElement("p"),b,e={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(a,null);for(var f in e)void 0!==a.style[f]&&(a.style[f]="translate3d(1px,1px,1px)",b=window.getComputedStyle(a).getPropertyValue(e[f]));document.body.removeChild(a);return void 0!==b&&0<b.length&&
"none"!==b}function fa(){return window.PointerEvent?{down:"pointerdown",move:"pointermove"}:{down:"MSPointerDown",move:"MSPointerMove"}}function S(a){var b=[];window.navigator.msPointerEnabled?(b.y=a.pageY,b.x=a.pageX):(b.y=a.touches[0].pageY,b.x=a.touches[0].pageX);return b}function I(c){var d=b.scrollingSpeed;a.fn.fullpage.setScrollingSpeed(0);x(c.closest(".fp-slides"),c);a.fn.fullpage.setScrollingSpeed(d)}function v(a){b.css3?X("translate3d(0px, -"+a+"px, 0px)",!1):h.css("top",-a)}function Z(a){return{"-webkit-transform":a,
"-moz-transform":a,"-ms-transform":a,transform:a}}function na(){v(0);a("#fp-nav, .fp-slidesNav, .fp-controlArrow").remove();a(".fp-section").css({height:"","background-color":"",padding:""});a(".fp-slide").css({width:""});h.css({height:"",position:"","-ms-touch-action":"","touch-action":""});a(".fp-section, .fp-slide").each(function(){ba(a(this));a(this).removeClass("fp-table active")});h.find(".fp-easing").removeClass("fp-easing");h.find(".fp-tableCell, .fp-slidesContainer, .fp-slides").each(function(){a(this).replaceWith(this.childNodes)});
a("html, body").scrollTop(0)}b=a.extend({verticalCentered:!0,resize:!0,sectionsColor:[],anchors:[],scrollingSpeed:700,easing:"easeInQuart",menu:!1,navigation:!1,navigationPosition:"right",navigationColor:"#000",navigationTooltips:[],slidesNavigation:!1,slidesNavPosition:"bottom",controlArrowColor:"#fff",loopBottom:!1,loopTop:!1,loopHorizontal:!0,autoScrolling:!0,fitSection:!1,scrollOverflow:!1,css3:!1,paddingTop:0,paddingBottom:0,fixedElements:null,normalScrollElements:null,keyboardScrolling:!0,touchSensitivity:5,
continuousVertical:!1,animateAnchor:!0,normalScrollElementTouchThreshold:5,sectionSelector:".section",slideSelector:".slide",afterLoad:null,onLeave:null,afterRender:null,afterResize:null,afterReBuild:null,afterSlideLoad:null,onSlideLeave:null},b);b.continuousVertical&&(b.loopTop||b.loopBottom)&&(b.continuousVertical=!1,console&&console.log&&console.log("Option loopTop/loopBottom is mutually exclusive with continuousVertical; continuousVertical disabled"));a.fn.fullpage.setAutoScrolling=function(c){b.autoScrolling=
c;c=a(".fp-section.active");b.autoScrolling?(a("html, body").css({overflow:"hidden",height:"100%"}),h.css({"-ms-touch-action":"none","touch-action":"none"}),c.length&&v(c.position().top)):(a("html, body").css({overflow:"visible",height:"initial"}),h.css({"-ms-touch-action":"","touch-action":""}),v(0),a("html, body").scrollTop(c.position().top))};a.fn.fullpage.setScrollingSpeed=function(a){b.scrollingSpeed=a};a.fn.fullpage.setMouseWheelScrolling=function(a){a?document.addEventListener?(document.addEventListener("mousewheel",
u,!1),document.addEventListener("wheel",u,!1)):document.attachEvent("onmousewheel",u):document.addEventListener?(document.removeEventListener("mousewheel",u,!1),document.removeEventListener("wheel",u,!1)):document.detachEvent("onmousewheel",u)};a.fn.fullpage.setAllowScrolling=function(b){if(b){if(a.fn.fullpage.setMouseWheelScrolling(!0),L||ga)MSPointer=fa(),a(document).off("touchstart "+MSPointer.down).on("touchstart "+MSPointer.down,ja),a(document).off("touchmove "+MSPointer.move).on("touchmove "+
MSPointer.move,ia)}else if(a.fn.fullpage.setMouseWheelScrolling(!1),L||ga)MSPointer=fa(),a(document).off("touchstart "+MSPointer.down),a(document).off("touchmove "+MSPointer.move)};a.fn.fullpage.setKeyboardScrolling=function(a){b.keyboardScrolling=a};a.fn.fullpage.moveSectionUp=function(){var c=a(".fp-section.active").prev(".fp-section");c.length||!b.loopTop&&!b.continuousVertical||(c=a(".fp-section").last());c.length&&q(c,null,!0)};a.fn.fullpage.moveSectionDown=function(){var c=a(".fp-section.active").next(".fp-section");
c.length||!b.loopBottom&&!b.continuousVertical||(c=a(".fp-section").first());c.length&&q(c,null,!1)};a.fn.fullpage.moveTo=function(b,d){var e="",e=isNaN(b)?a('[data-anchor="'+b+'"]'):a(".fp-section").eq(b-1);"undefined"!==typeof d?K(b,d):0<e.length&&q(e)};a.fn.fullpage.moveSlideRight=function(){T("next")};a.fn.fullpage.moveSlideLeft=function(){T("prev")};a.fn.fullpage.reBuild=function(c){D=!0;var d=a(window).width();r=a(window).height();b.resize&&ka(r,d);a(".fp-section").each(function(){parseInt(a(this).css("padding-bottom"));
parseInt(a(this).css("padding-top"));b.verticalCentered&&a(this).find(".fp-tableCell").css("height",da(a(this))+"px");a(this).css("height",r+"px");if(b.scrollOverflow){var c=a(this).find(".fp-slide");c.length?c.each(function(){y(a(this))}):y(a(this))}c=a(this).find(".fp-slides");c.length&&x(c,c.find(".fp-slide.active"))});a(".fp-section.active").position();d=a(".fp-section.active");d.index(".fp-section")&&q(d);D=!1;a.isFunction(b.afterResize)&&c&&b.afterResize.call(this);a.isFunction(b.afterReBuild)&&
!c&&b.afterReBuild.call(this)};var t=!1,L=navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|Windows Phone|Tizen|Bada)/),ga="ontouchstart"in window||0<navigator.msMaxTouchPoints,h=a(this),r=a(window).height(),p=!1,D=!1,w,J,m,W="fullpage-wrapper";a.fn.fullpage.setAllowScrolling(!0);b.css3&&(b.css3=ma());a(this).length?(h.css({height:"100%",position:"relative"}),h.addClass(W)):console.error("Error! Fullpage.js needs to be initialized with a selector. For example: $('#myContainer').fullpage();");
a(b.sectionSelector).each(function(){a(this).addClass("fp-section")});a(b.slideSelector).each(function(){a(this).addClass("fp-slide")});b.navigation&&ha();a(".fp-section").each(function(c){var d=a(this),e=a(this).find(".fp-slide"),f=e.length;c||0!==a(".fp-section.active").length||a(this).addClass("active");a(this).css("height",r+"px");(b.paddingTop||b.paddingBottom)&&a(this).css("padding",b.paddingTop+" 0 "+b.paddingBottom+" 0");"undefined"!==typeof b.sectionsColor[c]&&a(this).css("background-color",
b.sectionsColor[c]);"undefined"!==typeof b.anchors[c]&&a(this).attr("data-anchor",b.anchors[c]);if(1<f){c=100*f;var g=100/f;e.wrapAll('<div class="fp-slidesContainer" />');e.parent().wrap('<div class="fp-slides" />');a(this).find(".fp-slidesContainer").css("width",c+"%");a(this).find(".fp-slides").after('<div class="fp-controlArrow fp-prev"></div><div class="fp-controlArrow fp-next"></div>');"#fff"!=b.controlArrowColor&&(a(this).find(".fp-controlArrow.fp-next").css("border-color","transparent transparent transparent "+
b.controlArrowColor),a(this).find(".fp-controlArrow.fp-prev").css("border-color","transparent "+b.controlArrowColor+" transparent transparent"));b.loopHorizontal||a(this).find(".fp-controlArrow.fp-prev").hide();b.slidesNavigation&&la(a(this),f);e.each(function(c){a(this).css("width",g+"%");b.verticalCentered&&ca(a(this))});d=d.find(".fp-slide.active");0==d.length?e.eq(0).addClass("active"):I(d)}else b.verticalCentered&&ca(a(this))}).promise().done(function(){a.fn.fullpage.setAutoScrolling(b.autoScrolling);
var c=a(".fp-section.active").find(".fp-slide.active");c.length&&(0!=a(".fp-section.active").index(".fp-section")||0==a(".fp-section.active").index(".fp-section")&&0!=c.index())&&I(c);b.fixedElements&&b.css3&&a(b.fixedElements).appendTo("body");b.navigation&&(m.css("margin-top","-"+m.height()/2+"px"),m.find("li").eq(a(".fp-section.active").index(".fp-section")).find("a").addClass("active"));b.menu&&b.css3&&a(b.menu).closest(".fullpage-wrapper").length&&a(b.menu).appendTo("body");b.scrollOverflow?
("complete"===document.readyState&&M(),a(window).on("load",M)):a.isFunction(b.afterRender)&&b.afterRender.call(this);c=window.location.hash.replace("#","").split("/")[0];if(c.length){var d=a('[data-anchor="'+c+'"]');!b.animateAnchor&&d.length&&(b.autoScrolling?v(d.position().top):(v(0),a("html, body").scrollTop(d.position().top)),G(c),H(c,null),a.isFunction(b.afterLoad)&&b.afterLoad.call(this,c,d.index(".fp-section")+1),d.addClass("active").siblings().removeClass("active"))}a(window).on("load",function(){var a=
window.location.hash.replace("#","").split("/"),b=a[0],a=a[1];b&&K(b,a)})});a("html, body").bind("scroll mousedown DOMMouseScroll mousewheel keyup",function(){!b.autoScrolling&&b.fitSection&&(a("html, body").stop(),p=!1)});var O,P,E=!1;a(window).on("scroll",N);var s=0,B=0,l=0,A=0;a(window).on("hashchange",Y);a(document).keydown(function(c){if(b.keyboardScrolling&&!p)switch(c.which){case 38:case 33:a.fn.fullpage.moveSectionUp();break;case 40:case 34:a.fn.fullpage.moveSectionDown();break;case 36:a.fn.fullpage.moveTo(1);
break;case 35:a.fn.fullpage.moveTo(a(".fp-section").length);break;case 37:a.fn.fullpage.moveSlideLeft();break;case 39:a.fn.fullpage.moveSlideRight()}});a(document).on("click touchstart","#fp-nav a",function(b){b.preventDefault();b=a(this).parent().index();q(a(".fp-section").eq(b))});a(document).on("click touchstart",".fp-slidesNav a",function(b){b.preventDefault();b=a(this).closest(".fp-section").find(".fp-slides");var d=b.find(".fp-slide").eq(a(this).closest("li").index());x(b,d)});a(document).on({mouseenter:function(){var c=
a(this).data("tooltip");a('<div class="fp-tooltip '+b.navigationPosition+'">'+c+"</div>").hide().appendTo(a(this)).fadeIn(200)},mouseleave:function(){a(this).find(".fp-tooltip").fadeOut(200,function(){a(this).remove()})}},"#fp-nav li");b.normalScrollElements&&(a(document).on("mouseenter",b.normalScrollElements,function(){a.fn.fullpage.setMouseWheelScrolling(!1)}),a(document).on("mouseleave",b.normalScrollElements,function(){a.fn.fullpage.setMouseWheelScrolling(!0)}));a(".fp-section").on("click touchstart",
".fp-controlArrow",function(){a(this).hasClass("fp-prev")?a.fn.fullpage.moveSlideLeft():a.fn.fullpage.moveSlideRight()});a(window).resize($);var aa;a.fn.fullpage.destroy=function(c){a.fn.fullpage.setAutoScrolling(!1);a.fn.fullpage.setAllowScrolling(!1);a.fn.fullpage.setKeyboardScrolling(!1);a(window).off("scroll",N).off("hashchange",Y).off("resize",$);a(document).off("click","#fp-nav a").off("mouseenter","#fp-nav li").off("mouseleave","#fp-nav li").off("click",".fp-slidesNav a").off("mouseover",b.normalScrollElements).off("mouseout",
b.normalScrollElements);a(".fp-section").off("click",".fp-controlArrow");c&&na()}}})(jQuery);