Skip to content

Instantly share code, notes, and snippets.

@chrisjreber
Last active August 31, 2017 21:29
Show Gist options
  • Save chrisjreber/703a2437da7ba708a0b69e38ec3ee900 to your computer and use it in GitHub Desktop.
Save chrisjreber/703a2437da7ba708a0b69e38ec3ee900 to your computer and use it in GitHub Desktop.
$(function () {
$(".staff-filter__menu li").on('mouseenter mouseleave', function (e) {
if ($(this).children('ul').length) {
var elm = $(this).children('ul');
var off = elm.offset();
var l = off.left;
var w = elm.width();
var docW = $(window).width();
var isEntirelyVisible = (l + w + 20 <= docW);
if (!isEntirelyVisible) {
var difference = (l+w) - docW + 20;
$(this).children('ul').css("left", -difference);
} else {
$(this).children('ul').css("left", "0");
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment