Skip to content

Instantly share code, notes, and snippets.

@Sixl-Daniel
Created June 24, 2020 11:50
Show Gist options
  • Save Sixl-Daniel/19b82128241d971cc6c7833db34021cf to your computer and use it in GitHub Desktop.
Save Sixl-Daniel/19b82128241d971cc6c7833db34021cf to your computer and use it in GitHub Desktop.
jQuery Snippets
(function($) {
const
resizeThrottle = 200,
win = $(window),
html = $('html'),
body = $('body'),
btnMenu = $('#btn-main-menu'),
menu = $('#menu');
var winwidth = 0;
html.removeClass('no-js').addClass('js');
if(btnMenu.length) {
btnMenu.on('click', () => {
body.toggleClass('menu-open');
})
}
win.resize(() => {
clearTimeout(win.resizedFinished);
win.resizedFinished = setTimeout(() => {
winwidth = win.width();
console.log('Resized finished. Size: ' + winwidth + 'px');
}, resizeThrottle);
}).load(() => {
win.trigger('resize');
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment