Skip to content

Commit

Permalink
Don't reposition nMCollection for huge lists
Browse files Browse the repository at this point in the history
  • Loading branch information
LFDM committed Sep 12, 2014
1 parent 3417c7a commit 5536c8d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions app/js/arethusa.relation/directives/nested_menu_collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ angular.module('arethusa.relation').directive('nestedMenuCollection', [

if (element.hasClass('top-menu')) {
var items = Object.keys(scope.all || {}).length + 1; // an empty val
var menuHeight = items * 18; // hard to access, we therefore hardcode...
var maxHeight = win.height() - 15;
var topPos = element.parent().offset().top;
var bottom = topPos + menuHeight;
if (bottom > maxHeight) {
element.css({ top: 'auto', bottom: '100%'});
// Don't try to be clever when the list is really long. Chances are
// that repositioning would cause the menu to go beyond the upper
// border of the viewport, which is even worse.
if (items < 20) {
var menuHeight = items * 18; // hard to access, we therefore hardcode...
var maxHeight = win.height() - 15;
var topPos = element.parent().offset().top;
var bottom = topPos + menuHeight;
if (bottom > maxHeight) {
element.css({ top: 'auto', bottom: '100%'});
}
}
}
},
Expand Down

0 comments on commit 5536c8d

Please sign in to comment.