I am using document.body.getBoundingClientRect().right to find what all elements in my top navigation are going out of view, so as to hide them and put them under a 'More' dropdown. But the function does not seem to be working in safari. Is there any alternative to the function or is there some way I can make it fix in safari?
var windowRightOffset = document.body.getBoundingClientRect().right,
elementHiddenFlag = false;
$(".headerNav").find("li").each(function() {
if ($(this).className !== 'more') {
var elemRightOffset = $(this).find("a")[0].getBoundingClientRect().right;
if (elemRightOffset > windowRightOffset) {
$(this).hide();
elementHiddenFlag = true;
$(".more .moreNavItems-content").append($(this).html());
}
}
});