Difference between revisions of "Template:Team:Bielefeld-CeBiTec/JS"

(fixed moving small buttons)
(fixed moving small buttons complete)
Line 411: Line 411:
 
$middle = $(this).position().left + ($(this).width() * 0.5);
 
$middle = $(this).position().left + ($(this).width() * 0.5);
 
$totalWidth = 0;
 
$totalWidth = 0;
 +
$noEffect = 0;
 
 
 
$('.sub-navbar-item').each(function(i, obj) {
 
$('.sub-navbar-item').each(function(i, obj) {
 +
if (obj == $clickItem) {
 +
$noEffect = 1;
 +
}
 
if ($($clickItem).hasClass("sub-navbar-item")) {
 
if ($($clickItem).hasClass("sub-navbar-item")) {
$(".test").html("caseA");
 
 
if ($(obj).is(":visible")) {
 
if ($(obj).is(":visible")) {
 
if ($(obj).hasClass("small")) {
 
if ($(obj).hasClass("small")) {
Line 424: Line 427:
 
}
 
}
 
} else {
 
} else {
$(".test").html("caseB");
 
 
if ($(obj).is(":visible")) {
 
if ($(obj).is(":visible")) {
 
if ($totalWidth == 0) {
 
if ($totalWidth == 0) {
Line 433: Line 435:
 
}
 
}
 
});
 
});
$newPos = ($middle - ($totalWidth * 0.5));
+
if ($noEffect == 0) {
if ($newPos < 0) {
+
$newPos = ($middle - ($totalWidth * 0.5));
$newPos = 0;
+
if ($newPos < 0) {
 +
$newPos = 0;
 +
}
 +
if ($newPos + $totalWidth > $("body").width()) {
 +
$newPos = $("body").width() - $totalWidth;
 +
}
 +
$newPos = $newPos + "px";
 +
 +
$($leftItem).css({'margin-left':$newPos});
 
}
 
}
if ($newPos + $totalWidth > $("body").width()) {
 
$newPos = $("body").width() - $totalWidth;
 
}
 
$newPos = $newPos + "px";
 
 
$($leftItem).css({'margin-left':$newPos});
 
 
}
 
}
 
     });
 
     });
Line 466: Line 470:
 
resizeNavbar();
 
resizeNavbar();
 
}, 10);
 
}, 10);
 +
 +
  
  

Revision as of 15:11, 23 September 2017