m (probably final fix for new navbar) |
(fixed moving small buttons) |
||
Line 408: | Line 408: | ||
//get center x position of item and place subitems centered to this | //get center x position of item and place subitems centered to this | ||
− | $middle = $(this).position().left + ($(this).width() * 0.5); | + | if (!$(this).hasClass("small")) { |
− | + | $middle = $(this).position().left + ($(this).width() * 0.5); | |
− | + | $totalWidth = 0; | |
− | + | ||
− | + | $('.sub-navbar-item').each(function(i, obj) { | |
− | + | if ($($clickItem).hasClass("sub-navbar-item")) { | |
− | + | $(".test").html("caseA"); | |
− | + | if ($(obj).is(":visible")) { | |
+ | if ($(obj).hasClass("small")) { | ||
+ | if ($totalWidth == 0) { | ||
+ | $leftItem = obj; | ||
+ | } | ||
+ | $totalWidth = $totalWidth + $(obj).width(); | ||
+ | } | ||
+ | } | ||
+ | } else { | ||
+ | $(".test").html("caseB"); | ||
+ | if ($(obj).is(":visible")) { | ||
if ($totalWidth == 0) { | if ($totalWidth == 0) { | ||
$leftItem = obj; | $leftItem = obj; | ||
Line 422: | Line 432: | ||
} | } | ||
} | } | ||
− | } | + | }); |
− | + | $newPos = ($middle - ($totalWidth * 0.5)); | |
− | + | if ($newPos < 0) { | |
− | + | $newPos = 0; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
− | + | if ($newPos + $totalWidth > $("body").width()) { | |
− | + | $newPos = $("body").width() - $totalWidth; | |
− | + | } | |
− | + | $newPos = $newPos + "px"; | |
− | + | ||
− | + | $($leftItem).css({'margin-left':$newPos}); | |
− | + | ||
} | } | ||
− | |||
− | |||
− | |||
}); | }); | ||
}); | }); | ||
Line 464: | Line 466: | ||
resizeNavbar(); | resizeNavbar(); | ||
}, 10); | }, 10); | ||
− | |||
− | |||
Revision as of 15:02, 23 September 2017