/*! * headroom.js v0.11.0 - Give your page some headroom. Hide your header until you need it * Copyright (c) 2020 Nick Williams - http://wicky.nillia.ms/headroom.js * License: MIT */ !function(t,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(t=t||self).Headroom=s()}(this,(function(){"use strict";function t(){return"undefined"!=typeof window}function s(t){return(i=t)&&i.document&&function(t){return 9===t.nodeType}(i.document)?(o=(s=t).document,n=o.body,e=o.documentElement,{scrollHeight:function(){return Math.max(n.scrollHeight,e.scrollHeight,n.offsetHeight,e.offsetHeight,n.clientHeight,e.clientHeight)},height:function(){return s.innerHeight||e.clientHeight||n.clientHeight},scrollY:function(){return void 0!==s.pageYOffset?s.pageYOffset:(e||n.parentNode||n).scrollTop}}):function(t){return{scrollHeight:function(){return Math.max(t.scrollHeight,t.offsetHeight,t.clientHeight)},height:function(){return Math.max(t.offsetHeight,t.clientHeight)},scrollY:function(){return t.scrollTop}}}(t);var s,o,n,e,i}function o(t,o,n){var e,i=function(){var t=!1;try{var s={get passive(){t=!0}};window.addEventListener("test",s,s),window.removeEventListener("test",s,s)}catch(s){t=!1}return t}(),r=!1,a=s(t),l=a.scrollY(),c={};function h(){var t=Math.round(a.scrollY()),s=a.height(),e=a.scrollHeight();c.scrollY=t,c.lastScrollY=l,c.direction=t>l?"down":"up",c.distance=Math.abs(t-l),c.isOutOfBounds=t<0||t+s>e,c.top=t<=o.offset,c.bottom=t+s>=e,c.toleranceExceeded=c.distance>o.tolerance[c.direction],n(c),l=t,r=!1}function d(){r||(r=!0,e=requestAnimationFrame(h))}var u=!!i&&{passive:!0,capture:!1};return t.addEventListener("scroll",d,u),h(),{destroy:function(){cancelAnimationFrame(e),t.removeEventListener("scroll",d,u)}}}function n(t,s){var o;s=s||{},Object.assign(this,n.options,s),this.classes=Object.assign({},n.options.classes,s.classes),this.elem=t,this.tolerance=(o=this.tolerance)===Object(o)?o:{down:o,up:o},this.initialised=!1,this.frozen=!1}return n.prototype={constructor:n,init:function(){return n.cutsTheMustard&&!this.initialised&&(this.addClass("initial"),this.initialised=!0,setTimeout((function(t){t.scrollTracker=o(t.scroller,{offset:t.offset,tolerance:t.tolerance},t.update.bind(t))}),100,this)),this},destroy:function(){this.initialised=!1,Object.keys(this.classes).forEach(this.removeClass,this),this.scrollTracker.destroy()},unpin:function(){!this.hasClass("pinned")&&this.hasClass("unpinned")||(this.addClass("unpinned"),this.removeClass("pinned"),this.onUnpin&&this.onUnpin.call(this))},pin:function(){this.hasClass("unpinned")&&(this.addClass("pinned"),this.removeClass("unpinned"),this.onPin&&this.onPin.call(this))},freeze:function(){this.frozen=!0,this.addClass("frozen")},unfreeze:function(){this.frozen=!1,this.removeClass("frozen")},top:function(){this.hasClass("top")||(this.addClass("top"),this.removeClass("notTop"),this.onTop&&this.onTop.call(this))},notTop:function(){this.hasClass("notTop")||(this.addClass("notTop"),this.removeClass("top"),this.onNotTop&&this.onNotTop.call(this))},bottom:function(){this.hasClass("bottom")||(this.addClass("bottom"),this.removeClass("notBottom"),this.onBottom&&this.onBottom.call(this))},notBottom:function(){this.hasClass("notBottom")||(this.addClass("notBottom"),this.removeClass("bottom"),this.onNotBottom&&this.onNotBottom.call(this))},shouldUnpin:function(t){return"down"===t.direction&&!t.top&&t.toleranceExceeded},shouldPin:function(t){return"up"===t.direction&&t.toleranceExceeded||t.top},addClass:function(t){this.elem.classList.add.apply(this.elem.classList,this.classes[t].split(" "))},removeClass:function(t){this.elem.classList.remove.apply(this.elem.classList,this.classes[t].split(" "))},hasClass:function(t){return this.classes[t].split(" ").every((function(t){return this.classList.contains(t)}),this.elem)},update:function(t){t.isOutOfBounds||!0!==this.frozen&&(t.top?this.top():this.notTop(),t.bottom?this.bottom():this.notBottom(),this.shouldUnpin(t)?this.unpin():this.shouldPin(t)&&this.pin())}},n.options={tolerance:{up:0,down:0},offset:0,scroller:t()?window:null,classes:{frozen:"headroom--frozen",pinned:"headroom--pinned",unpinned:"headroom--unpinned",top:"headroom--top",notTop:"headroom--not-top",bottom:"headroom--bottom",notBottom:"headroom--not-bottom",initial:"headroom"}},n.cutsTheMustard=!!(t()&&function(){}.bind&&"classList"in document.documentElement&&Object.assign&&Object.keys&&requestAnimationFrame),n}));