Created
June 24, 2020 11:50
-
-
Save Sixl-Daniel/19b82128241d971cc6c7833db34021cf to your computer and use it in GitHub Desktop.
jQuery Snippets
This file contains 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
(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