Last Updated: February 25, 2016
·
1.278K
· hi_dm

Faster Twitter Bootstrap Mobile Navigation

I have noticed that there is a half second or so delay between when you touch the .navbar-toggle and when the dropdown menu flies out.

This short delay might relate to how mobile browsers detect a click(). It seems that binding touchstart() to .navbar-toggle does the trick.

$(document).ready(function(){
     $('.navbar-toggle').bind( "touchstart", function(e){
         e.preventDefault();
         $('.navbar-collapse').collapse('toggle');
    });
});

It's important to note that touchstart() will interfere with mobile scrolling, so if your "hamburger" or .navbar-toggle target is larger than default it might be better to avoid this patch.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip