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