1/*! 2 * jQuery Scrollify 3 * Version 1.0.21 4 * 5 * Requires: 6 * - jQuery 1.7 or higher 7 * 8 * https://github.com/lukehaas/Scrollify 9 * 10 * Copyright 2016, Luke Haas 11 * Permission is hereby granted, free of charge, to any person obtaining a copy of 12 * this software and associated documentation files (the "Software"), to deal in 13 * the Software without restriction, including without limitation the rights to 14 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 * the Software, and to permit persons to whom the Software is furnished to do so, 16 * subject to the following conditions: 17 * 18 * The above copyright notice and this permission notice shall be included in all 19 * copies or substantial portions of the Software. 20 * 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 28 29 30if touchScroll is false - update index 31 32 */ 33(function(global,factory){"use strict";if(typeof define==='function'&&define.amd){define(['jquery'],function($){return factory($,global,global.document)})}else if(typeof module==='object'&&module.exports){module.exports=factory(require('jquery'),global,global.document)}else{factory(jQuery,global,global.document)}}(typeof window!=='undefined'?window:this,function($,window,document,undefined){"use strict";var heights=[],names=[],elements=[],overflow=[],index=0,currentIndex=0,interstitialIndex=1,hasLocation=!1,timeoutId,timeoutId2,$window=$(window),portHeight,top=$window.scrollTop(),scrollable=!1,locked=!1,scrolled=!1,manualScroll,swipeScroll,util,disabled=!1,scrollSamples=[],scrollTime=new Date().getTime(),firstLoad=!0,initialised=!1,destination=0,wheelEvent='onwheel' in document?'wheel':document.onmousewheel!==undefined?'mousewheel':'DOMMouseScroll',eventListenerOptions={passive:!1},settings={section:".section",sectionName:"section-name",interstitialSection:"",easing:"easeOutExpo",scrollSpeed:1100,offset:0,scrollbars:!0,target:"html,body",standardScrollElements:!1,setHeights:!0,overflowScroll:!0,updateHash:!0,touchScroll:!0,before:function(){},after:function(){},afterResize:function(){},afterRender:function(){}};function getportHeight(){return(window.innerHeight+settings.offset)} 34function animateScroll(index,instant,callbacks,toTop){if(currentIndex===index){callbacks=!1} 35if(disabled===!0){return!0} 36if(names[index]){scrollable=!1;if(firstLoad===!0){firstLoad=!1;settings.afterRender()} 37if(callbacks){if(typeof settings.before=='function'&&settings.before(index,elements)===!1){return!0}} 38interstitialIndex=1;destination=(!index)?0:heights[index];if(firstLoad===!1&¤tIndex>index&&toTop===!1){if(overflow[index]){portHeight=getportHeight();interstitialIndex=parseInt(elements[index].outerHeight()/portHeight);destination=parseInt(heights[index])+(elements[index].outerHeight()-portHeight)}} 39if(settings.updateHash&&settings.sectionName&&!(firstLoad===!0&&index===0)){if(history.pushState){try{history.replaceState(null,null,names[index])}catch(e){if(window.console){console.warn("Scrollify warning: Page must be hosted to manipulate the hash value.")}}}else{window.location.hash=names[index]}} 40currentIndex=index;if(instant){$(settings.target).stop().scrollTop(destination);if(callbacks){settings.after(index,elements)}}else{locked=!0;if($().velocity){$(settings.target).stop().velocity('scroll',{duration:settings.scrollSpeed,easing:settings.easing,offset:destination,mobileHA:!1})}else{$(settings.target).stop().animate({scrollTop:destination},settings.scrollSpeed,settings.easing)} 41if(window.location.hash.length&&settings.sectionName&&window.console){try{if($(window.location.hash).length){console.warn("Scrollify warning: ID matches hash value - this will cause the page to anchor.")}}catch(e){}} 42$(settings.target).promise().done(function(){locked=!1;firstLoad=!1;if(callbacks){settings.after(index,elements)}})}}} 43function isAccelerating(samples){function average(num){var sum=0;var lastElements=samples.slice(Math.max(samples.length-num,1));for(var i=0;i<lastElements.length;i++){sum+=lastElements[i]} 44return Math.ceil(sum/num)} 45var avEnd=average(10);var avMiddle=average(70);if(avEnd>=avMiddle){return!0}else{return!1}} 46var scrollify=function(options){initialised=!0;$.easing.easeOutExpo=function(x,t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b};manualScroll={handleMousedown:function(){if(disabled===!0){return!0} 47scrollable=!1;scrolled=!1},handleMouseup:function(){if(disabled===!0){return!0} 48scrollable=!0;if(scrolled){manualScroll.calculateNearest(!1,!0)}},handleScroll:function(){if(disabled===!0){return!0} 49if(timeoutId){clearTimeout(timeoutId)} 50timeoutId=setTimeout(function(){scrolled=!0;if(scrollable===!1){return!1} 51scrollable=!1;manualScroll.calculateNearest(!1,!0)},200)},calculateNearest:function(instant,callbacks){top=$window.scrollTop();var i=1,max=heights.length,closest=0,prev=Math.abs(heights[0]-top),diff;for(;i<max;i++){diff=Math.abs(heights[i]-top);if(diff<prev){prev=diff;closest=i}} 52if((atBottom()&&closest>
52index)||atTop()){index=closest;animateScroll(closest,instant,callbacks,!1)}},wheelHandler:function(e){if(disabled===!0){return!0}else if(settings.standardScrollElements){if($(e.target).is(settings.standardScrollElements)||$(e.target).closest(settings.standardScrollElements).length){return!0}} 53if(!overflow[index]){e.preventDefault()} 54var currentScrollTime=new Date().getTime();e=e||window.event;var value;if(e.originalEvent){value=e.originalEvent.wheelDelta||-e.originalEvent.deltaY||-e.originalEvent.detail}else{value=e.wheelDelta||-e.deltaY||-e.detail} 55var delta=Math.max(-1,Math.min(1,value));if(scrollSamples.length>149){scrollSamples.shift()} 56scrollSamples.push(Math.abs(value));if((currentScrollTime-scrollTime)>200){scrollSamples=[]} 57scrollTime=currentScrollTime;if(locked){return!1} 58if(delta<0){if(index<heights.length-1){if(atBottom()){if(isAccelerating(scrollSamples)){e.preventDefault();index++;locked=!0;animateScroll(index,!1,!0,!1)}else{return!1}}}}else if(delta>0){if(index>0){if(atTop()){if(isAccelerating(scrollSamples)){e.preventDefault();index--;locked=!0;animateScroll(index,!1,!0,!1)}else{return!1}}}}},keyHandler:function(e){if(disabled===!0||document.activeElement.readOnly===!1){return!0}else if(settings.standardScrollElements){if($(e.target).is(settings.standardScrollElements)||$(e.target).closest(settings.standardScrollElements).length){return!0}} 59if(locked===!0){return!1} 60if(e.keyCode==38||e.keyCode==33){if(index>0){if(atTop()){e.preventDefault();index--;animateScroll(index,!1,!0,!1)}}}else if(e.keyCode==40||e.keyCode==34){if(index<heights.length-1){if(atBottom()){e.preventDefault();index++;animateScroll(index,!1,!0,!1)}}}},init:function(){if(settings.scrollbars){$window.on('mousedown',manualScroll.handleMousedown);$window.on('mouseup',manualScroll.handleMouseup);$window.on('scroll',manualScroll.handleScroll)}else{$("body").css({"overflow":"hidden"})} 61window.addEventListener(wheelEvent,manualScroll.wheelHandler,{passive:!1});$window.on('keydown',manualScroll.keyHandler)}};swipeScroll={touches:{"touchstart":{"y":-1,"x":-1},"touchmove":{"y":-1,"x":-1},"touchend":!1,"direction":"undetermined"},options:{"distance":30,"timeGap":800,"timeStamp":new Date().getTime()},touchHandler:function(event){if(disabled===!0){return!0}else if(settings.standardScrollElements){if($(event.target).is(settings.standardScrollElements)||$(event.target).closest(settings.standardScrollElements).length){return!0}} 62var touch;if(typeof event!=='undefined'){if(typeof event.touches!=='undefined'){touch=event.touches[0];switch(event.type){case 'touchstart':swipeScroll.touches.touchstart.y=touch.pageY;swipeScroll.touches.touchmove.y=-1;swipeScroll.touches.touchstart.x=touch.pageX;swipeScroll.touches.touchmove.x=-1;swipeScroll.options.timeStamp=new Date().getTime();swipeScroll.touches.touchend=!1;case 'touchmove':swipeScroll.touches.touchmove.y=touch.pageY;swipeScroll.touches.touchmove.x=touch.pageX;if(swipeScroll.touches.touchstart.y!==swipeScroll.touches.touchmove.y&&(Math.abs(swipeScroll.touches.touchstart.y-swipeScroll.touches.touchmove.y)>Math.abs(swipeScroll.touches.touchstart.x-swipeScroll.touches.touchmove.x))){event.preventDefault();swipeScroll.touches.direction="y";if((swipeScroll.options.timeStamp+swipeScroll.options.timeGap)<(new Date().getTime())&&swipeScroll.touches.touchend==!1){swipeScroll.touches.touchend=!0;if(swipeScroll.touches.touchstart.y>-1){if(Math.abs(swipeScroll.touches.touchmove.y-swipeScroll.touches.touchstart.y)>swipeScroll.options.distance){if(swipeScroll.touches.touchstart.y<swipeScroll.touches.touchmove.y){swipeScroll.up()}else{swipeScroll.down()}}}}} 63break;case 'touchend':if(swipeScroll.touches[event.type]===!1){swipeScroll.touches[event.type]=!0;if(swipeScroll.touches.touchstart.y>-1&&swipeScroll.touches.touchmove.y>-1&&swipeScroll.touches.direction==="y"){if(Math.abs(swipeScroll.touches.touchmove.y-swipeScroll.touches.touchstart.y)>swipeScroll.options.distance){if(swipeScroll.touches.touchstart.y<swipeScroll.touches.touchmove.y){swipeScroll.up()}else{swipeScroll.down()}} 64swipeScroll.touches.touchstart.y=-1;swipeScroll.touches.touchstart.x=-1;swipeScroll.touches.direction="undetermined"}} 65default:break}}}},down:function(){if(index<heights.length){if(atBottom()&&index<heights.length-1){index++;
65animateScroll(index,!1,!0,!1)}else{portHeight=getportHeight();if(Math.floor(elements[index].height()/portHeight)>interstitialIndex){interstitialScroll(parseInt(heights[index])+(portHeight*interstitialIndex));interstitialIndex+=1}else{interstitialScroll(parseInt(heights[index])+(elements[index].outerHeight()-portHeight))}}}},up:function(){if(index>=0){if(atTop()&&index>0){index--;animateScroll(index,!1,!0,!1)}else{if(interstitialIndex>2){portHeight=getportHeight();interstitialIndex-=1;interstitialScroll(parseInt(heights[index])+(portHeight*interstitialIndex))}else{interstitialIndex=1;interstitialScroll(parseInt(heights[index]))}}}},init:function(){if(document.addEventListener&&settings.touchScroll){document.addEventListener('touchstart',swipeScroll.touchHandler,eventListenerOptions);document.addEventListener('touchmove',swipeScroll.touchHandler,eventListenerOptions);document.addEventListener('touchend',swipeScroll.touchHandler,eventListenerOptions)}}};util={refresh:function(withCallback,scroll){clearTimeout(timeoutId2);timeoutId2=setTimeout(function(){sizePanels(!0);calculatePositions(scroll,!1);if(withCallback){settings.afterResize()}},400)},handleUpdate:function(){util.refresh(!1,!1)},handleResize:function(){util.refresh(!0,!1)},handleOrientation:function(){util.refresh(!0,!0)}};settings=$.extend(settings,options);sizePanels(!1);calculatePositions(!1,!0);if(!0===hasLocation){animateScroll(index,!1,!0,!0)}else{setTimeout(function(){manualScroll.calculateNearest(!0,!1)},200)} 66if(heights.length){manualScroll.init();swipeScroll.init();$window.on("resize",util.handleResize);if(document.addEventListener){window.addEventListener("orientationchange",util.handleOrientation,!1)}} 67function interstitialScroll(pos){if($().velocity){$(settings.target).stop().velocity('scroll',{duration:settings.scrollSpeed,easing:settings.easing,offset:pos,mobileHA:!1})}else{$(settings.target).stop().animate({scrollTop:pos},settings.scrollSpeed,settings.easing)}} 68function sizePanels(keepPosition){if(keepPosition){top=$window.scrollTop()} 69var selector=settings.section;overflow=[];if(settings.interstitialSection.length){selector+=","+settings.interstitialSection} 70if(settings.scrollbars===!1){settings.overflowScroll=!1} 71portHeight=getportHeight();$(selector).each(function(i){var $this=$(this);if(settings.setHeights){if($this.is(settings.interstitialSection)){overflow[i]=!1}else{if(($this.css("height","auto").outerHeight()<portHeight)||$this.css("overflow")==="hidden"){$this.css({"height":portHeight});overflow[i]=!1}else{$this.css({"height":$this.outerHeight()});if(settings.overflowScroll){overflow[i]=!0}else{overflow[i]=!1}}}}else{if(($this.outerHeight()<portHeight)||(settings.overflowScroll===!1)){overflow[i]=!1}else{overflow[i]=!0}}});if(keepPosition){$window.scrollTop(top)}} 72function calculatePositions(scroll,firstLoad){var selector=settings.section;if(settings.interstitialSection.length){selector+=","+settings.interstitialSection} 73heights=[];names=[];elements=[];$(selector).each(function(i){var $this=$(this);if(i>0){heights[i]=parseInt($this.offset().top)+settings.offset}else{heights[i]=parseInt($this.offset().top)} 74if(settings.sectionName&&$this.data(settings.sectionName)){names[i]="#"+$this.data(settings.sectionName).toString().replace(/ /g,"-")}else{if($this.is(settings.interstitialSection)===!1){names[i]="#"+(i+1)}else{names[i]="#";if(i===$(selector).length-1&&i>1){heights[i]=heights[i-1]+(parseInt($($(selector)[i-1]).outerHeight())-parseInt($(window).height()))+parseInt($this.outerHeight())}}} 75elements[i]=$this;try{if($(names[i]).length&&window.console){console.warn("Scrollify warning: Section names can't match IDs - this will cause the browser to anchor.")}}catch(e){} 76if(window.location.hash===names[i]){index=i;hasLocation=!0}});if(!0===scroll){animateScroll(index,!1,!1,!1)}} 77function atTop(){if(!overflow[index]){return!0} 78top=$window.scrollTop();if(top>parseInt(heights[index])){return!1}else{return!0}} 79function atBottom(){if(!overflow[index]){return!0} 80top=$window.scrollTop();portHeight=getportHeight();if(top<parseInt(heights[index])+(elements[index].outerHeight()-portHeight)-28){return!1}else{return!0}}} 81function move(panel,instant){var z=names.length;for(;z>=0;z--){if(typeof panel==='string'){if(names[z]===panel){index=z;animateScroll(z,instant,!0,!0)}}else{if(z===panel){index=z;animateScroll(z,instant,!0,!0)}}}} 82scrollify.move=function(panel){if(panel===undefined){return!1} 83if(typeof panel!=="number"&&panel.originalEvent){panel=$(this).attr("href")} 84move(panel,!1)};scrollify.instantMove=function(panel){if(panel===undefined){return!1}
85move(panel,!0)};scrollify.next=function(){if(index<names.length){index+=1;animateScroll(index,!1,!0,!0)}};scrollify.previous=function(){if(index>0){index-=1;animateScroll(index,!1,!0,!0)}};scrollify.instantNext=function(){if(index<names.length){index+=1;animateScroll(index,!0,!0,!0)}};scrollify.instantPrevious=function(){if(index>0){index-=1;animateScroll(index,!0,!0,!0)}};scrollify.destroy=function(){if(!initialised){return!1} 86if(settings.setHeights){$(settings.section).each(function(){$(this).css("height","auto")})} 87$window.off("resize",util.handleResize);if(settings.scrollbars){$window.off('mousedown',manualScroll.handleMousedown);$window.off('mouseup',manualScroll.handleMouseup);$window.off('scroll',manualScroll.handleScroll)} 88window.removeEventListener(wheelEvent,manualScroll.wheelHandler);$window.off('keydown',manualScroll.keyHandler);if(document.addEventListener&&settings.touchScroll){document.removeEventListener('touchstart',swipeScroll.touchHandler,eventListenerOptions);document.removeEventListener('touchmove',swipeScroll.touchHandler,eventListenerOptions);document.removeEventListener('touchend',swipeScroll.touchHandler,eventListenerOptions)} 89heights=[];names=[];elements=[];overflow=[];firstLoad=!0;initialised=!1};scrollify.update=function(){if(!initialised){return!1} 90util.handleUpdate()};scrollify.current=function(){return elements[index]};scrollify.currentIndex=function(){return index};scrollify.disable=function(){disabled=!0};scrollify.enable=function(){disabled=!1;if(initialised){manualScroll.calculateNearest(!1,!1)}};scrollify.isDisabled=function(){return disabled};scrollify.setOptions=function(updatedOptions){if(!initialised){return!1} 91if(typeof updatedOptions==="object"){settings=$.extend(settings,updatedOptions);util.handleUpdate()}else if(window.console){console.warn("Scrollify warning: setOptions expects an object.")}};$.scrollify=scrollify;return scrollify}))
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.