Skip to content

Instantly share code, notes, and snippets.

@rodleviton
Last active August 29, 2015 14:01
Show Gist options
  • Save rodleviton/19504d4dc076c69f2b1f to your computer and use it in GitHub Desktop.
Save rodleviton/19504d4dc076c69f2b1f to your computer and use it in GitHub Desktop.
Bootstrap Mega Menu Responsive Intelligence
// Handle Mega Menu Positioning
// Requires Yamm Mega Menu Plugin for Bootstrap3 (http://geedmo.github.io/yamm3/)
$('li.dropdown > a').on('click', function () {
var screenWidth = $(window).width();
var xPos = $(this).offset().left;
var parent = $(this).parent('.dropdown');
var dropdownWidth = $('.dropdown-menu', parent).width();
if ((xPos + dropdownWidth) > screenWidth) {
$('.dropdown-menu', parent).addClass('pull-right');
} else {
$('.dropdown-menu', parent).removeClass('pull-right');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment