/*! * headroom.js v0.9.4 - Give your page some headroom. Hide your header until you need it * Copyright (c) 2017 Nick Williams - http://wicky.nillia.ms/headroom.js * License: MIT */ !function(a,b){"use strict";"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?module.exports=b():a.Headroom=b()}(this,function(){"use strict";function a(a){this.callback=a,this.ticking=!1}function b(a){return a&&"undefined"!=typeof window&&(a===window||a.nodeType)}function c(a){if(arguments.length<=0)throw new Error("Missing arguments in extend function");var d,e,f=a||{};for(e=1;ethis.getScrollerHeight();return b||c},toleranceExceeded:function(a,b){return Math.abs(a-this.lastKnownScrollY)>=this.tolerance[b]},shouldUnpin:function(a,b){var c=a>this.lastKnownScrollY,d=a>=this.offset;return c&&d&&b},shouldPin:function(a,b){var c=athis.lastKnownScrollY?"down":"up",c=this.toleranceExceeded(a,b);this.isOutOfBounds(a)||(a<=this.offset?this.top():this.notTop(),a+this.getViewportHeight()>=this.getScrollerHeight()?this.bottom():this.notBottom(),this.shouldUnpin(a,c)?this.unpin():this.shouldPin(a,c)&&this.pin(),this.lastKnownScrollY=a)}},e.options={tolerance:{up:0,down:0},offset:140,scroller:window,classes:{pinned:"headroom--pinned",unpinned:"headroom--unpinned",top:"headroom--top",notTop:"headroom--not-top",bottom:"headroom--bottom",notBottom:"headroom--not-bottom",initial:"headroom"}},e.cutsTheMustard="undefined"!=typeof f&&f.rAF&&f.bind&&f.classList,e}); (function($) { if(!$) { return; } //////////// // Plugin // //////////// $.fn.headroom = function(option) { return this.each(function() { var $this = $(this), data = $this.data('headroom'), options = typeof option === 'object' && option; options = $.extend(true, {}, Headroom.options, options); if (!data) { data = new Headroom(this, options); data.init(); $this.data('headroom', data); } if (typeof option === 'string') { data[option](); if(option === 'destroy'){ $this.removeData('headroom'); } } }); }; ////////////// // Data API // ////////////// $('[data-headroom]').each(function() { var $this = $(this); $this.headroom($this.data()); }); }(window.Zepto || window.jQuery));