Im trying to write a function where I click a hamburger menu, and it opens, then clicked again it closes. I've tried many examples, but it always returns an error of "Cannot read property 'pattern' of undefined" the second time I click the menu. The example I'm referencing is here https://codepen.io/filippo/pen/WvGbJB?editors=1010. Am I missing something here?
My code is as follows:
$('.menu').click( function ( event ) {
if( $(event.target).hasClass('open') ) {
$('.full-menu').velocity({ width: "0%" }, { duration: 100 });
$('.menu').removeClass('open');
$('.full-menu').addClass('hide-menu');
} else {
$('.full-menu').velocity({ width: "100%" }, { duration: 100 });
$('.full-menu').removeClass('hide-menu');
$('.menu').addClass('open');
bindmenus()
}
});