Skip to content

Instantly share code, notes, and snippets.

@awps
Last active May 17, 2017 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awps/c6b096d82956c777079ba04a3d14d12d to your computer and use it in GitHub Desktop.
Save awps/c6b096d82956c777079ba04a3d14d12d to your computer and use it in GitHub Desktop.
// Source: https://gist.github.com/Smartik89/c6b096d82956c777079ba04a3d14d12d/
function smk_menu_sticky( _menu, _sticky_class, _container, _top ){
_container = _container || window;
_sticky_class = _sticky_class || 'sticky-menu';
_menu = _menu || '.main-menu';
_top = _top || 300;
$( _container ).scroll(function () {
if ($(this).scrollTop() > _top) {
$( _menu ).addClass( _sticky_class );
} else {
$( _menu ).removeClass( _sticky_class );
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment