Created
June 4, 2015 15:53
-
-
Save coquer/9913074f41cee4c816e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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