jquery - Stop slideToggle from bouncing on resize -



jquery - Stop slideToggle from bouncing on resize -

i have responsive menu hidden under 590px , displayed on width.

this code works on $(window).ready lame on resize.

$(window).resize(function () { if ($(window).width() > 0 && $(window).width() < 590){ $('.container').click(function() { $( '.category' ).slidetoggle(); }); } else if ($(window).width() > 591){ $( '.category' ).show(); } });

indeed, menu triggered multiple times after resizing.

it seems mutual issue don't know how tackle it.

///////////// edit ///////////

found way out using .unbind stop bouncing. hope helps else.

function slidemenu(){ $( '.menu' ).slidetoggle(); } $(window).on('resize',function () { if ($(window).width() > 0 && $(window).width() < 590){ $('.menu').hide(); $('.container').unbind('click', slidemenu); $('.container').on('click', slidemenu); } else if ($(window).width() > 591){ $('.menu').show(); $('.container').off('click', slidemenu); } }).trigger('resize');

jquery responsive-design slidetoggle

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -