This repository has been archived by the owner on Mar 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
takeoff-complete.min.js
1 lines (1 loc) · 11.4 KB
/
takeoff-complete.min.js
1
(function(){"use strict";function t(){}function e(t,e){for(var n=t.length;n--;)if(t[n].listener===e)return n;return-1}function n(t){return function(){return this[t].apply(this,arguments)}}var i=t.prototype,r=this,o=r.EventEmitter;i.getListeners=function(t){var e,n,i=this._getEvents();if(t instanceof RegExp){e={};for(n in i)i.hasOwnProperty(n)&&t.test(n)&&(e[n]=i[n])}else e=i[t]||(i[t]=[]);return e},i.flattenListeners=function(t){var e,n=[];for(e=0;e<t.length;e+=1)n.push(t[e].listener);return n},i.getListenersAsObject=function(t){var e,n=this.getListeners(t);return n instanceof Array&&(e={},e[t]=n),e||n},i.addListener=function(t,n){var i,r=this.getListenersAsObject(t),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===e(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(t,e){return this.addListener(t,{listener:e,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(t){return this.getListeners(t),this},i.defineEvents=function(t){for(var e=0;e<t.length;e+=1)this.defineEvent(t[e]);return this},i.removeListener=function(t,n){var i,r,o=this.getListenersAsObject(t);for(r in o)o.hasOwnProperty(r)&&(i=e(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(t,e){return this.manipulateListeners(!1,t,e)},i.removeListeners=function(t,e){return this.manipulateListeners(!0,t,e)},i.manipulateListeners=function(t,e,n){var i,r,o=t?this.removeListener:this.addListener,s=t?this.removeListeners:this.addListeners;if("object"!=typeof e||e instanceof RegExp)for(i=n.length;i--;)o.call(this,e,n[i]);else for(i in e)e.hasOwnProperty(i)&&(r=e[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(t){var e,n=typeof t,i=this._getEvents();if("string"===n)delete i[t];else if(t instanceof RegExp)for(e in i)i.hasOwnProperty(e)&&t.test(e)&&delete i[e];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(t,e){var n,i,r,o,s,a=this.getListenersAsObject(t);for(o in a)if(a.hasOwnProperty(o))for(n=a[o].slice(0),r=n.length;r--;)i=n[r],i.once===!0&&this.removeListener(t,i.listener),s=i.listener.apply(this,e||[]),s===this._getOnceReturnValue()&&this.removeListener(t,i.listener);return this},i.trigger=n("emitEvent"),i.emit=function(t){var e=Array.prototype.slice.call(arguments,1);return this.emitEvent(t,e)},i.setOnceReturnValue=function(t){return this._onceReturnValue=t,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return r.EventEmitter=o,t},"function"==typeof define&&define.amd?define(function(){return t}):"object"==typeof module&&module.exports?module.exports=t:r.EventEmitter=t}).call(this),function(){var t;t="undefined"!=typeof exports&&null!==exports?exports:this,t.Lethargy=function(){function t(t,e,n,i){this.stability=null!=t?Math.abs(t):8,this.sensitivity=null!=e?1+Math.abs(e):100,this.tolerance=null!=n?1+Math.abs(n):1.1,this.delay=null!=i?i:150,this.lastUpDeltas=function(){var t,e,n;for(n=[],t=1,e=2*this.stability;e>=1?e>=t:t>=e;e>=1?t++:t--)n.push(null);return n}.call(this),this.lastDownDeltas=function(){var t,e,n;for(n=[],t=1,e=2*this.stability;e>=1?e>=t:t>=e;e>=1?t++:t--)n.push(null);return n}.call(this),this.deltasTimestamp=function(){var t,e,n;for(n=[],t=1,e=2*this.stability;e>=1?e>=t:t>=e;e>=1?t++:t--)n.push(null);return n}.call(this)}return t.prototype.check=function(t){var e;return t=t.originalEvent||t,null!=t.wheelDelta?e=t.wheelDelta:null!=t.deltaY?e=-40*t.deltaY:(null!=t.detail||0===t.detail)&&(e=-40*t.detail),this.deltasTimestamp.push(Date.now()),this.deltasTimestamp.shift(),e>0?(this.lastUpDeltas.push(e),this.lastUpDeltas.shift(),this.isInertia(1)):(this.lastDownDeltas.push(e),this.lastDownDeltas.shift(),this.isInertia(-1))},t.prototype.isInertia=function(t){var e,n,i,r,o,s,a;return e=-1===t?this.lastDownDeltas:this.lastUpDeltas,null===e[0]?t:this.deltasTimestamp[2*this.stability-2]+this.delay>Date.now()&&e[0]===e[2*this.stability-1]?!1:(i=e.slice(0,this.stability),n=e.slice(this.stability,2*this.stability),a=i.reduce(function(t,e){return t+e}),o=n.reduce(function(t,e){return t+e}),s=a/i.length,r=o/n.length,Math.abs(s)<Math.abs(r*this.tolerance)&&this.sensitivity<Math.abs(r)?t:!1)},t.prototype.showLastUpDeltas=function(){return this.lastUpDeltas},t.prototype.showLastDownDeltas=function(){return this.lastDownDeltas},t}()}.call(this),function(t){var e,n="mousewheel DOMMouseScroll wheel MozMousePixelScroll";"undefined"!=typeof Lethargy&&null!==Lethargy&&(e=new Lethargy);var i=function(){return Math.max(window.pageYOffset,window.document.body.scrollTop,window.document.documentElement.scrollTop)};t.smartscroll=function(r){var o=t.extend({},t.smartscroll.defaults,r);if(o.sectionSelector||(o.sectionSelector="."+o.sectionClass),("undefined"==typeof EventEmitter||null===EventEmitter||o.eventEmitter&&o.eventEmitter.constructor!==EventEmitter)&&(o.eventEmitter=null),o.bindSwipe)var s=null,a=null,l=function(t){var t=t.originalEvent||t;s=t.touches[0].clientX,a=t.touches[0].clientY},c=function(t){var t=t.originalEvent||t;if(s&&a){var e=t.touches[0].clientX,n=t.touches[0].clientY,i=s-e,r=a-n;Math.abs(i)>Math.abs(r)?i>0?o.eventEmitter.emitEvent("swipeLeft"):o.eventEmitter.emitEvent("swipeRight"):r>0?o.eventEmitter.emitEvent("swipeUp"):o.eventEmitter.emitEvent("swipeDown"),s=null,a=null}};var u,h,f=!1,d=[],p=!1,v=!1,m=window.location.hash,w=t(o.sectionWrapperSelector+":first"),g=function(){var e=i(),n=e+t(window).height();return n>u&&h>=e?!0:!1},E=function(e,n){f||(f=!0,t("body,html").stop(!0,!0).animate({scrollTop:e},n,function(){f=!1,o.eventEmitter&&o.eventEmitter.emitEvent("scrollEnd")}))};this.scroll=function(e){if(d){var n=i();if(o.eventEmitter){var r=k(n+t(window).height()/2),s=e?r+1:r-1;o.eventEmitter.emitEvent("scrollStart",[s])}for(var a=0;a<d.length;a++)if(n<d[a])return e?E(d[a],700):E(d[a-1]-t(window).height(),700),o.eventEmitter&&o.eventEmitter.emitEvent("scrollEnd"),!1}};var b=function(){var e=[];u=Math.round(w.position().top+parseInt(w.css("paddingTop"),10)+parseInt(w.css("borderTopWidth"),10)+parseInt(w.css("marginTop"),10)),h=Math.round(u+w.height(),10),e.push(u),t(o.sectionSelector).each(function(n,i){e.push(Math.round(u+t(i).position().top+t(i).outerHeight()))}),d=e},y=function(t){if(e)var n=e.check(t);if(!f)if(e){if(1===n)return"up";if(-1===n)return"down"}else{if(t.originalEvent.wheelDelta>0||t.originalEvent.detail<0)return"up";if(t.originalEvent.wheelDelta<0||t.originalEvent.detail>0)return"down"}return!1},k=function(t){for(var e=0;e<d.length;e++)if(t<=d[e])return e;return d.length},S=function(){t(window).bind(n,function(e){var n=y(e);o.dynamicHeight&&b(),g();var r=i(),s=r+t(window).height();if(s>u&&h>=r){var a=k(r),l=k(r+t(window).height()/2),c=k(s);a===c&&o.innerSectionScroll||(e.preventDefault(),e.stopPropagation(),n&&("up"===n?(o.toptotop?E(d[l-2]+1,o.animationSpeed):E(d[l-1]-t(window).height(),o.animationSpeed),o.eventEmitter&&o.eventEmitter.emitEvent("scrollStart",[l-1])):"down"===n&&(E(d[l]+1,o.animationSpeed),o.eventEmitter&&o.eventEmitter.emitEvent("scrollStart",[l+1]))))}})},_=function(){t(window).unbind(n)},L=function(){var e;if(i()+t(window).height()/2<u)e=o.headerHash;else{var n=k(i()+t(window).height()/2);void 0!==n&&(e=t(o.sectionSelector+":nth-of-type("+(n+1)+")").data("hash"))}("undefined"==typeof e||window.location.hash!=="#"+e)&&("undefined"==typeof e&&(e=o.headerHash),o.keepHistory?window.location.hash=e:window.location.replace(window.location.href.split("#")[0]+"#"+e))};if(w.css({position:"relative"}),setTimeout(function(){if(b(),o.autoHash&&(null===o.eventEmitter||o.hashContinuousUpdate?t(window).bind("scroll",L):o.eventEmitter.addListener("scrollEnd",L)),o.initialScroll&&m.length>0){var e=t('[data-hash="'+m.substr(1)+'"]');e.length>0&&E(e[0].offsetTop+u,0)}},50),t(window).bind("resize",b),null!==o.breakpoint&&o.breakpoint===parseInt(o.breakpoint,10)&&o.breakpoint>0&&(p=!0),"vp"==o.mode)if(o.ie8){var D=function(){t(o.sectionSelector).css({height:t(window).height()})};D(),t(window).bind("resize",D)}else t(o.sectionSelector).css({height:"100vh"});if(o.sectionScroll&&(p&&t(window).bind("resize",function(e){if(t(window).width()<o.breakpoint){if(!v)return _(),v=!0,!1}else v&&(S(),v=!1)}),S()),o.bindSwipe&&(t(window).on("touchstart",l),t(window).on("touchmove",c)),o.bindKeyboard){var x=function(e){e=e.originalEvent||e,o.dynamicHeight&&b();var n=i(),r=n+t(window).height();if(g()){var s=k(n),a=k(n+t(window).height()/2),l=k(r);if(s!==l||!o.innerSectionScroll)switch(e.which){case 38:e.preventDefault(),e.stopPropagation(),o.toptotop?E(d[a-2]+1,o.animationSpeed):E(d[a-1]-t(window).height(),o.animationSpeed),o.eventEmitter&&o.eventEmitter.emitEvent("scrollStart",[a-1]);break;case 40:e.preventDefault(),e.stopPropagation(),E(d[a]+1,o.animationSpeed),o.eventEmitter&&o.eventEmitter.emitEvent("scrollStart",[a+1]);break;default:return}}};t(window).on("keydown",x)}return this},t.smartscroll.defaults={animationSpeed:700,autoHash:!0,breakpoint:null,initialScroll:!0,headerHash:"header",keepHistory:!1,mode:"vp",sectionClass:"section",sectionSelector:null,sectionScroll:!0,sectionWrapperSelector:".section-wrapper",eventEmitter:null,dynamicHeight:!1,ie8:!1,hashContinuousUpdate:!0,innerSectionScroll:!0,toptotop:!1,bindSwipe:!0,bindKeyboard:!0}}(jQuery),function(t){t.takeoff=function(e){var n=t.extend({},t.takeoff.defaults,e),i=[],r=new EventEmitter,o=t(".takeoff__backgrounds"),s=(t(".takeoff__backgroundBlock").length,!0),a=!0,l=t.smartscroll({mode:"set",autoHash:!1,sectionScroll:!0,initialScroll:!1,keepHistory:!1,sectionWrapperSelector:".takeoff__backgrounds",sectionSelector:".takeoff__backgroundBlock",animationSpeed:700,headerHash:"header",breakpoint:null,innerSectionScroll:!1,ie8:!1,toptotop:!0,eventEmitter:r});n.changingBackground===!0&&(t(".takeoff__backgroundBlock").each(function(e,n){i.push(t(n).data("tfBackgroundColor")||"#ffffff")}),t("body").css({backgroundColor:t(".takeoff__backgroundBlock:first").data("tfBackgroundColor")}));var c=function(){l.scroll(1)};t(".takeoff__nextSlide").on("click",c);var u=function(){l.scroll(1)},h=function(){l.scroll(0)};r.addListener("swipeUp",u),r.addListener("swipeDown",h);var f=function(t){s||a||(s=a=!0,d(t),v(t),p(t))},d=function(e){n.changingBackground===!0&&t("body").css({backgroundColor:i[e-1]})},p=function(e){e=Math.min(Math.max(e-1,0),t(".takeoff__screens img").length-1);var i=t(".takeoff__screens img.current").eq(0),r=t(".takeoff__screens img").eq(e);return r.is(i)?(a=!1,!1):(i.css("z-index",5),r.css("z-index",6),void r.animate({top:0},{duration:n.slideDuration,easing:"swing",complete:function(){i.removeClass("current"),r.addClass("current"),i.removeAttr("style"),a=!1}}))},v=function(e){e=Math.min(Math.max(e-1,0),t(".takeoff__textblock").length-1);var i=t(".takeoff__textblock.current").eq(0),r=t(".takeoff__textblock").eq(e);return i.is(r)?(s=!1,!1):(r.css("z-index",5),i.animate({opacity:0,top:"-50px"},{duration:400,easing:"swing",complete:function(){i.removeClass("current"),i.removeAttr("style")}}),void r.animate({top:0},{duration:n.slideDuration,easing:"swing",complete:function(){r.addClass("current"),s=!1}}))};return r.addListeners("scrollStart",[f]),t(".takeoff__screens img").eq(0).add(t(".takeoff__textblock").eq(0)).animate({top:0},{duration:400,easing:"swing",complete:function(){t(".takeoff__screens img").eq(0).add(t(".takeoff__textblock").eq(0)).addClass("current"),s=a=!1}}),t(document).ready(function(){t("html,body").animate({scrollTop:0},1e3)}),o},t.takeoff.defaults={changingBackground:!0,slideDuration:700}}(jQuery);