Skip to content

Instantly share code, notes, and snippets.

View Morgul's full-sized avatar
🎮
Godlike Fuzzydice

Christopher S. Case Morgul

🎮
Godlike Fuzzydice
View GitHub Profile
@Morgul
Morgul / gist:6043382
Created July 20, 2013 01:04
Potential fix for Bootstrap's poor menu detection of screen edges.
$(".dropdown-toggle").click(function(e) {
var menu = $(this).next('.dropdown-menu'),
mousex = e.pageX + 20, //Get X coodrinates
mousey = e.pageY + 20, //Get Y coordinates
menuWidth = menu.width(), //Find width of tooltip
menuHeight = menu.height(), //Find height of tooltip
menuVisX = $(window).width() - (mousex + menuWidth), //Distance of element from the right edge of viewport
menuVisY = $(window).height() - (mousey + menuHeight); //Distance of element from the bottom of viewport
if (menuVisX < 20) { //If tooltip exceeds the X coordinate of viewport