'); this.stickyWrap = $('
'); var container = $(".site-header").parents('.grid-framework'); $( '.universal-banner, .site-header' ).each( function( index, element ) { this.stickyWrap.append( $( element ).clone() ); $( element ).addClass( 'sticky-header-cloned' ); }.bind( this ) ); this.sticky.append(this.stickyWrap); $(".sticky-header-container").append(this.sticky); } StickyHeader.prototype.triggerDisappear = function(){ this.sticky.addClass('at-scroll-top'); this.isVisible = false; this.currentHeight = 0; this.sticky.css('height',this.currentHeight); $("body").removeClass("sticky-header-active"); $("body").removeClass('sticky-header-expanded'); } StickyHeader.prototype.triggerAppear = function(){ if ($("body").hasClass('slider-is-open')) return; this.isVisible = true; $("body").addClass("sticky-header-active"); } StickyHeader.prototype.triggerExpand = function(){ if (this.disabled) return; if ($("body").hasClass('slider-is-open')) return; if (this.currentHeight == this.maxHeight) return; this.sticky.css('height',this.maxHeight-1); this.currentHeight = this.maxHeight; $("body").addClass('sticky-header-expanded'); } StickyHeader.prototype.triggerShrink = function(){ if ($( '.ua-mobile, .ua-tablet' ).length == 0 || !$(".page-header").hasClass('page-header-online')) { this.sticky.removeClass('at-scroll-top'); } var self = this; window.requestAnimationFrame(function(){ var newHeight = 0; if (self.isVisible) { newHeight = self.minHeight; } if (self.currentHeight == newHeight) return; self.sticky.css('height',newHeight); self.currentHeight = newHeight; $("body").removeClass('sticky-header-expanded'); }) } StickyHeader.prototype.redraw = function() { // This is costly to performance but unavoidable //const pageY = window.scrollY; //This throws a syntax error in IE11. var pageY = window.pageYOffset; var scrollUp = pageY 10) { this.velocitySamples.shift(); } var totalDistance = 0; for (var i = 0;i' + k + ': '+v +''; }) this.debug.html(html); if (pageY >= this.appearsAt) { this.triggerAppear(); } if ($(".page-header").hasClass('page-header-online') && $('.table-of-contents-wrapper').length && $('.table-of-contents-wrapper.jump-to').length == 0){ var tocWrap = $('.table-of-contents-wrapper'); var toc = tocWrap.children('.table-of-contents'); var tocItems = toc.find('.toc-item'); var stickyHeight = this.maxHeight; if ((pageY + stickyHeight) > tocWrap.offset().top && !toc.hasClass('sticky')) { toc.addClass('sticky'); } else if ((pageY + stickyHeight) sectionTop) && !$(this).hasClass('current')) { tocItems.removeClass('current'); $(this).addClass('current'); } else if ((pageHeight 5 || pageY this.appearsAt) { // If HBS online and mobile hide the sticky header if ($(".page-header").hasClass('page-header-online') && $( '.ua-mobile, .ua-tablet' ).length > 0) { this.triggerDisappear(); } this.triggerShrink(); } this.lastScrollTop = pageY; } this.hasScrolled = false; }; var _domready = _domready || []; _domready.push(function(){ if (document.getElementById('wcm-react-root')) return; if (window.stickyHeaderDisabled) return; window.stickyHeader = new StickyHeader(); var _onScroll = function () { if (!window.stickyHeader.hasScrolled) { window.requestAnimationFrame(function(){ window.stickyHeader.redraw(); }); } window.stickyHeader.hasScrolled = true; window.requestAnimationFrame(_onScroll); }; _onScroll(); //without this, the header flickers on online window.setTimeout(function(){ _onScroll(); },250) $(document).on('delay-sticky-nav',function(){ window.stickyHeader.temporarilyDisabled(); }) // needed for facet pages http://www.hbs.edu/news/Pages/default.aspx $(document).on('click',".facetctrl-sticky.active",function(){ $(document).trigger('delay-sticky-nav'); }) $(document).on('click',".filter-sticky.fixed",function(){ $(document).trigger('delay-sticky-nav'); }) });