Skip to content

Instantly share code, notes, and snippets.

@agaerig
Created April 2, 2013 14:39
Show Gist options
  • Save agaerig/5292724 to your computer and use it in GitHub Desktop.
Save agaerig/5292724 to your computer and use it in GitHub Desktop.
pmf.LockingHeader = Backbone.View.extend({
initialize: function() {
_.bindAll(this, 'on_page_scroll');
$(window).scroll(this.on_page_scroll);
},
on_page_scroll: function() {
var t = document.getElementById('nav-boundary').getBoundingClientRect().top;
var nav = this.$el.find('#horizontal-nav');
if(t < 0) {
if(!nav.hasClass('fixed')){
nav.addClass('fixed');
nav.find('#sections a').addClass('change');
nav.find('#horizontal-logo').stop().fadeIn(300);
nav.find('.social').addClass('purple');
}
} else {
nav.removeClass('fixed');
nav.find('#sections a').removeClass('change');
nav.find('#horizontal-logo').stop().fadeOut(50);
nav.find('.social').removeClass('purple');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment