Merge pull request #430 from ClemDee/responsiveContextMenu

Make context submenus don't overflow on Y axis
pull/1/head
ansuz 5 years ago committed by GitHub
commit 30671cd570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,10 +29,6 @@
.dropdown-menu {
top: -0.7rem;
left: 100%;
&.left {
left: 0%;
transform: translate(-100%);
}
}
}
a {

@ -498,10 +498,16 @@ define([
var $el = $(el);
var $a = $el.children().filter("a");
var $sub = $el.find(".dropdown-menu").first();
var left, bottomOffset;
var timeoutId;
var showSubmenu = function () {
clearTimeout(timeoutId);
$sub.toggleClass("left", $el.offset().left + $el.outerWidth() + $sub.outerWidth() > $(window).width());
left = $el.offset().left + $el.outerWidth() + $sub.outerWidth() > $(window).width();
bottomOffset = $el.offset().top + $el.outerHeight() + $sub.outerHeight() - $(window).height();
$sub.css("left", left ? "0%": "100%");
$sub.css("transform", "translate("
+ (left ? "-100%" : "0")
+ "," + (bottomOffset > 0 ? -(bottomOffset - $el.outerHeight()) : 0) + "px)");
$el.siblings().find(".dropdown-menu").hide();
$sub.show();
};

Loading…
Cancel
Save