Skip to content

Instantly share code, notes, and snippets.

@coquer
Created June 4, 2015 15:53
Show Gist options
  • Save coquer/9913074f41cee4c816e4 to your computer and use it in GitHub Desktop.
Save coquer/9913074f41cee4c816e4 to your computer and use it in GitHub Desktop.
window.onscroll = function(){
var _postion_top = document.documentElement.scrollTop || document.body.scrollTop,
_header_element = document.getElementById('site-navigation'),
class_name = "box_shadow";
console.log("poss - > " + _postion_top);
if(_postion_top > 340){
if (_header_element.classList){
_header_element.classList.add(class_name);
} else{
_header_element.className += ' ' + class_name;
}
}else{
if(_postion_top < 340){
if (_header_element.classList) {
_header_element.classList.remove(class_name);
}else {
_header_element.className = _header_element.className.replace(new RegExp('(^|\\b)' + class_name.split(' ').join('|') + '(\\b|jQuery)', 'gi'), ' ');
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment