Here is how problem looks like:
While it should look like:
Here is function used to create poping up overflowing menu:
function updateMenu(){
var lastItemIndex = Number.POSITIVE_INFINITY;
var lastItemText = "";
var maxWidth = 0;
var overflowCount=0;
var navHeight = $('.nav').height();
$('.nav li').each(function(i,e){
console.log($(e).position().top);
if($(e).position().top>=navHeight){
if(i<lastItemIndex) lastItemIndex=i-1;
if($(e).width()>maxWidth) maxWidth = $(e).width();
overflowCount++;
}
});
maxWidth = Math.max(maxWidth,$('.nav li:eq('+(lastItemIndex)+')').width());
var moreHeight = (overflowCount+2)*navHeight;
$('#moreMenu').remove();
if(overflowCount>0){
$('<ul id="moreMenu"/>').appendTo('body').width(maxWidth+16).height(navHeight);
$('#moreMenu').offset($('.nav li:eq('+(lastItemIndex)+')').offset());
$('#moreMenu').append('<li>More...</li>');
$('.nav li:gt('+(lastItemIndex-1)+')').each(function(i,e){
$('#moreMenu').append('<li>'+$(e).html()+'</li>');
});
$('#moreMenu').hover(
function(){$(this).height(moreHeight);},
function(){$(this).height(navHeight);});
}
}
And here is life jsfiddle demo of this bug (I use chrome for testing).
I wonder what is wrong with my updateMenu function, why when all menu items shall be shown in a pop up menu none is actually shown (and no html pushed into pop up menu object)?
Update fire fox also shows no items for me: