You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
9.6 KiB

"use strict";/*!
* EDITED BY LIQUID THEMES *
* pagepiling.js 1.5.5
*
* https://github.com/alvarotrigo/pagePiling.js
* @license MIT licensed
*
* Copyright (C) 2016 alvarotrigo.com - A project by Alvaro Trigo
*/
!function($,e,n,t){$.fn.pagepiling=function(o){function i(e){e.addClass("pp-table").wrapInner('<div class="pp-tableCell" style="height:100%" />')}function a(e){return $(".pp-section.active").index(".pp-section")>e.index(".pp-section")?"up":"down"}function s(e,n){var t={destination:e,animated:n,activeSection:$(".pp-section.active"),anchorLink:e.data("anchor"),sectionIndex:e.index(".pp-section"),toMove:e,yMovement:a(e),leavingSection:$(".pp-section.active").index(".pp-section")+1};if(!t.activeSection.is(e)){if(void 0===t.animated&&(t.animated=!0),void 0!==t.anchorLink&&u(t.anchorLink,t.sectionIndex),t.destination.addClass("active").siblings().removeClass("active"),t.sectionsToMove=l(t),"down"===t.yMovement){if(t.translate3d=q(),t.destination.is(".pp-auto-height")){var o=-1*t.destination.outerHeight()+"px";t.translate3d="translate3d(0px, "+o+", 0px)",t.scrolling=o,t.sectionsToMove=t.activeSection}else t.scrolling="-100%";Z.css3||t.sectionsToMove.each(function(e){e!=t.activeSection.index(".pp-section")&&$(this).css(d(t.scrolling))}),t.animateSection=t.activeSection}else t.translate3d="translate3d(0px, 0px, 0px)",t.scrolling="0",t.animateSection=e;$.isFunction(Z.onLeave)&&Z.onLeave.call(this,t.leavingSection,t.sectionIndex+1,t.yMovement),c(t),U(t.anchorLink),A(t.anchorLink,t.sectionIndex),F=t.anchorLink;var i=(new Date).getTime();H=i}}function c(e){Z.css3?(w(e.animateSection,e.translate3d,e.animated),e.sectionsToMove.each(function(){w($(this),e.translate3d,e.animated)}),setTimeout(function(){r(e)},Z.scrollingSpeed)):(e.scrollOptions=d(e.scrolling),e.animated?e.animateSection.animate(e.scrollOptions,Z.scrollingSpeed,Z.easing,function(){p(e),r(e)}):(e.animateSection.css(d(e.scrolling)),setTimeout(function(){p(e),r(e)},400)))}function r(e){$.isFunction(Z.afterLoad)&&Z.afterLoad.call(this,e.anchorLink,e.sectionIndex+1)}function l(e){var n;return n="down"===e.yMovement?$(".pp-section").map(function(n){if(n<e.destination.index(".pp-section"))return $(this)}):$(".pp-section").map(function(n){if(n>e.destination.index(".pp-section"))return $(this)})}function p(e){"up"===e.yMovement&&e.sectionsToMove.each(function(n){$(this).css(d(e.scrolling))})}function d(e){return"vertical"===Z.direction?{top:e}:{left:e}}function v(e,n){Z.css3?w(e,q(),!1):e.css(d(n))}function u(e,n){Z.anchors.length?(location.hash=e,h(location.hash)):h(String(n))}function h(e){e=e.replace("#",""),$("body")[0].className=$("body")[0].className.replace(/\b\s?pp-viewing-[^\s]+\b/g,""),$("body").addClass("pp-viewing-"+e)}function f(){var t=n.location.hash.replace("#",""),o=t,i=$(e).find('.pp-section[data-anchor="'+o+'"]');i.length>0&&s(i,Z.animateAnchor)}function m(){return(new Date).getTime()-H<J+Z.scrollingSpeed}function g(){var t=n.location.hash.replace("#","").split("/"),o=t[0];if(o.length&&o&&o!==F){var i;i=isNaN(o)?$(e).find('[data-anchor="'+o+'"]'):$(".pp-section").eq(o-1),s(i)}}function S(e){return{"-webkit-transform":e,"-moz-transform":e,"-ms-transform":e,transform:e}}function w(e,n,t){e.css(S(n))}function b(e){var t=(new Date).getTime();e=e||n.event;var o=e.wheelDelta||-e.deltaY||-e.detail,i=Math.max(-1,Math.min(1,o)),a=void 0!==e.wheelDeltaX||void 0!==e.deltaX,s=Math.abs(e.wheelDeltaX)<Math.abs(e.wheelDelta)||Math.abs(e.deltaX)<Math.abs(e.deltaY)||!a;G.length>149&&G.shift(),G.push(Math.abs(o));var c=t-ee;if(ee=t,c>200&&(G=[]),!m()){var r=$(".pp-section.active"),l=T(r);return x(G,10)>=x(G,70)&&s&&(i<0?M("down",l):i>0&&M("up",l)),!1}}function x(e,n){for(var t=0,o=e.slice(Math.max(e.length-n,1)),i=0;i<o.length;i++)t+=o[i];return Math.ceil(t/n)}function M(e,n){var t,o;if("down"==e?(t="bottom",o=O.moveSectionDown):(t="top",o=O.moveSectionUp),n.length>0){if(!y(t,n))return!0;o()}else o()}function y(e,n){return"top"===e?!n.scrollTop():"bottom"===e?n.scrollTop()+1+n.innerHeight()>=n[0].scrollHeight:void 0}function T(e){return e.filter(".pp-scrollable")}function C(){B.get(0).addEventListener?(B.get(0).removeEventListener("mousewheel",b,!1),B.get(0).removeEventListener("wheel",b,!1)):B.get(0).detachEvent("onmousewheel",b)}function k(){B.get(0).addEventListener?(B.get(0).addEventListener("mousewheel",b,!1),B.get(0).addEventListener("wheel",b,!1)):B.get(0).attachEvent("onmousewheel",b)}function E(){if(Q){var e=D();B.off("touchstart "+e.down).on("touchstart "+e.down,P),B.off("touchmove "+e.move).on("touchmove "+e.move,Y)}}function L(){if(Q){var e=D();B.off("touchstart "+e.down),B.off("touchmove "+e.move)}}function D(){var e;return e=n.PointerEvent?{down:"pointerdown",move:"pointermove",up:"pointerup"}:{down:"MSPointerDown",move:"MSPointerMove",up:"MSPointerUp"}}function X(e){var n=new Array;return n.y=void 0!==e.pageY&&(e.pageY||e.pageX)?e.pageY:e.touches[0].pageY,n.x=void 0!==e.pageX&&(e.pageY||e.pageX)?e.pageX:e.touches[0].pageX,n}function I(e){return void 0===e.pointerType||"mouse"!=e.pointerType}function P(e){var n=e.originalEvent;if(I(n)){var t=X(n);R=t.y,j=t.x}}function Y(e){var n=e.originalEvent;if(!N(e.target)&&I(n)){var t=$(".pp-section.active"),o=T(t);if(o.length||e.preventDefault(),!m()){var i=X(n);K=i.y,V=i.x,"horizontal"===Z.direction&&Math.abs(j-V)>Math.abs(R-K)?Math.abs(j-V)>B.width()/100*Z.touchSensitivity&&(j>V?M("down",o):V>j&&M("up",o)):Math.abs(R-K)>B.height()/100*Z.touchSensitivity&&(R>K?M("down",o):K>R&&M("up",o))}}}function N(e,n){n=n||0;var t=$(e).parent();return!!(n<Z.normalScrollElementTouchThreshold&&t.is(Z.normalScrollElements))||n!=Z.normalScrollElementTouchThreshold&&N(t,++n)}function z(){$("body").append('<div id="pp-nav"><ul></ul></div>');var e=$("#pp-nav");e.addClass(Z.navigation.position);for(var n=0;n<$(".pp-section").length;n++){var t="";if(Z.anchors.length&&(t=Z.anchors[n]),"undefined"!==Z.navigation.tooltips){var o=Z.navigation.tooltips[n];void 0===o&&(o="")}e.find("ul").append('<li data-tooltip="'+o+'">\n\t\t\t\t\t\t\t<a href="#'+t+'">\n\t\t\t\t\t\t\t\t<span></span>\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t<span class="pp-tooltip '+Z.navigation.position+'">'+o+"</span>\n\t\t\t\t\t\t</li>")}}function A(e,n){Z.navigation&&($("#pp-nav").find(".active").removeClass("active"),e?$("#pp-nav").find('a[href="#'+e+'"]').addClass("active"):$("#pp-nav").find("li").eq(n).find("a").addClass("active"))}function U(e){Z.menu&&($(Z.menu).find(".active").removeClass("active"),$(Z.menu).find('[data-menuanchor="'+e+'"]').addClass("active"))}function W(){var o=e.createElement("p"),i,a={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};e.body.insertBefore(o,null);for(var s in a)o.style[s]!==t&&(o.style[s]="translate3d(1px,1px,1px)",i=n.getComputedStyle(o).getPropertyValue(a[s]));return e.body.removeChild(o),i!==t&&i.length>0&&"none"!==i}function q(){return"vertical"!==Z.direction?"translate3d(-100%, 0px, 0px)":"translate3d(0px, -100%, 0px)"}var O=$.fn.pagepiling,B=$(this),F,H=0,Q="ontouchstart"in n||navigator.msMaxTouchPoints>0||navigator.maxTouchPoints,R=0,j=0,K=0,V=0,G=[],J=600,Z=$.extend(!0,{direction:"vertical",menu:null,verticalCentered:!0,sectionsColor:[],anchors:[],scrollingSpeed:700,easing:"easeInQuart",loopBottom:!1,loopTop:!1,css3:!0,navigation:{textColor:"#000",bulletsColor:"#000",position:"right",tooltips:[]},normalScrollElements:null,normalScrollElementTouchThreshold:5,touchSensitivity:5,keyboardScrolling:!0,sectionSelector:".section",animateAnchor:!1,afterLoad:null,onLeave:null,afterRender:null},o);$.extend($.easing,{easeInQuart:function e(n,t,o,i,a){return i*(t/=a)*t*t*t+o}}),O.setScrollingSpeed=function(e){Z.scrollingSpeed=e},O.setMouseWheelScrolling=function(e){e?k():C()},O.setAllowScrolling=function(e){e?(O.setMouseWheelScrolling(!0),E()):(O.setMouseWheelScrolling(!1),L())},O.setKeyboardScrolling=function(e){Z.keyboardScrolling=e},O.moveSectionUp=function(){var e=$(".pp-section.active").prev(".pp-section");!e.length&&Z.loopTop&&(e=$(".pp-section").last()),e.length&&s(e)},O.moveSectionDown=function(){var e=$(".pp-section.active").next(".pp-section");!e.length&&Z.loopBottom&&(e=$(".pp-section").first()),e.length&&s(e)},O.moveTo=function(n){var t="";t=isNaN(n)?$(e).find('[data-anchor="'+n+'"]'):$(".pp-section").eq(n-1),t.length>0&&s(t)},$(Z.sectionSelector).each(function(){$(this).addClass("pp-section")}),Z.css3&&(Z.css3=W()),$(B).css({overflow:"hidden","-ms-touch-action":"none","touch-action":"none"}),O.setAllowScrolling(!0),$.isEmptyObject(Z.navigation)||z();var _=$(".pp-section").length;$(".pp-section").each(function(e){$(this).data("data-index",e),$(this).css("z-index",_),e||0!==$(".pp-section.active").length||$(this).addClass("active"),void 0!==Z.anchors[e]&&$(this).attr("data-anchor",Z.anchors[e]),void 0!==Z.sectionsColor[e]&&$(this).css("background-color",Z.sectionsColor[e]),Z.verticalCentered&&!$(this).hasClass("pp-scrollable")&&i($(this)),_-=1}).promise().done(function(){Z.navigation&&$("#pp-nav").find("li").eq($(".pp-section.active").index(".pp-section")).find("a").addClass("active"),$(n).on("load",function(){f()}),$.isFunction(Z.afterRender)&&Z.afterRender.call(this)}),$(n).on("hashchange",g),$(e).keydown(function(e){if(Z.keyboardScrolling&&!m())switch(e.which){case 38:case 33:O.moveSectionUp();break;case 40:case 34:O.moveSectionDown();break;case 36:O.moveTo(1);break;case 35:O.moveTo($(".pp-section").length);break;case 37:O.moveSectionUp();break;case 39:O.moveSectionDown();break;default:return}}),Z.normalScrollElements&&($(e).on("mouseenter",Z.normalScrollElements,function(){O.setMouseWheelScrolling(!1)}),$(e).on("mouseleave",Z.normalScrollElements,function(){O.setMouseWheelScrolling(!0)}));var ee=(new Date).getTime()}}(jQuery,document,window);