Created
August 31, 2014 22:08
-
-
Save locii/b000a6240efbceed85d3 to your computer and use it in GitHub Desktop.
Test if dropdown menu is off the screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".dropdown li").on('mouseenter mouseleave', function (e) { | |
var elm = $('ul:first', this); | |
var off = elm .offset(); | |
var l = off.left; | |
var w = elm.width(); | |
var docW = $(".container").width(); | |
var isEntirelyVisible = (l+ w <= docW); | |
if ( ! isEntirelyVisible ) { | |
$(this).addClass('edge'); | |
} else { | |
$(this).removeClass('edge'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment