Skip to content

Instantly share code, notes, and snippets.

@awps
Last active May 17, 2017
Embed
What would you like to do?
// 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