Portál AbcLinuxu, 9. května 2025 02:38
var foundActive = false, activeElement, indicatorPosition, indicator = $('#cssmenu #menu-indicator'), defaultPosition, storage; $("#cssmenu > ul > li").each(function() { if ($(this).hasClass('active')) { $(this).addClass('active'); activeElement = $(this); foundActive = true; } else { } }); if (foundActive === false) { activeElement = $("#sipka").first(); } defaultPosition = indicatorPosition = activeElement.position().left + activeElement.width()/2 - 5; storage = defaultPosition; console.log(activeElement); console.log(activeElement.position().left); console.log(activeElement.width()); indicator.css("left", indicatorPosition); $("#logo").hover(function() { activeElement = $("#sipka"); indicatorPosition = activeElement.position().left + activeElement.width()/2 - 5; indicator.css("left", indicatorPosition); }, function() { indicator.css("left", defaultPosition); }); $("#logo").click(function () { //reset the selected item activeElement = $("#sipka").first(); indicatorPosition = activeElement.position().left + activeElement.width()/2 - 5; defaultPosition = indicatorPosition; }); function scrollOn(event){ var scrollPos = $(document).scrollTop(); $('#cssmenu > ul > li').each(function () { var currLink = $(this); var refElement = $(currLink.attr("href")); if (refElement.position().top <= scrollPos && refElement.position().top + refElement.height() > scrollPos) { activeElement = currLink; indicatorPosition = activeElement.position().left + activeElement.width()/2 - 5; defaultPosition = indicatorPosition; } else{ } } ); } $("#cssmenu > ul > li").hover(function() { activeElement = $(this); indicatorPosition = activeElement.position().left + activeElement.width()/2 - 5; indicator.css("left", indicatorPosition); }, function() { indicator.css("left", defaultPosition); }); $("#cssmenu > ul > li").click(function () { activeElement = $(this); indicatorPosition = activeElement.position().left + activeElement.width()/2 - 5; defaultPosition = indicatorPosition; });
Na otázku zatím nikdo bohužel neodpověděl.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.