• 0

[jQurery] Help with a menu transition effect please


Question

Hello all,

Im currently working on a new website and a new drop down menu using this tutorial

So far, this is what i have. It all seems to be working OK so far, but i dont like the fade transition its using. I would prefer something more like on the Nvidia site where there isnt a "fade lag".

I tried to use jQuery's FadeIn transition instead of the current fadeTo - but it just seemed to break the whole menu. So, how do i go about changing the transition effects (and trying some out), simply copying and pasting over the current fadeTo doesnt seem to work?

Thanks for any help

This is the code:

<script type="text/javascript">
$(document).ready(function() {

	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();

		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 

		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							 
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});

		} else { //If row does not exist...			
			//Set Width 
 	$(this).calcSubWidth(); 

 	var o = $(this).find('.sub').offset();
 	var p = $('#megaMenu').offset();
 	var pw = document.getElementById('megaMenu').clientWidth;
 	var tw = rowWidth;
 	o.left = o.left - p.left;
 	var tml = (tw + o.left) - pw;

 	$(this).find(".sub").css({'width' : rowWidth}).css({'margin-left':'-' + tml - 20 + 'px'}); 
		}
	}

	function megaHoverOut(){ 
	 $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		 $(this).css({'margin-left':'0'});
 	$(this).hide(); 
	 });
	}

	var config = {	
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)	
		 interval: 100, // number = milliseconds for onMouseOver polling interval	
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)	
		 timeout: 500, // number = milliseconds delay before onMouseOut	
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)	
	};	

	$("ul#topnav li .sub").css({'opacity':'0'}); 
	$("ul#topnav li").hoverIntent(config);
});
</script> 	

2 answers to this question

Recommended Posts

  • 0

If you want to use FadeIn and FadeOut, you have to remove all the "opacity"-things in the css file (and in the bottom of your javascript-code) for this selector and set the "display" to "none". FadeIn and Out toggles this from none to normal, with a fade-effect :D

(Btw, on the nvidia site, the menu's do not fade on my pc, they just appear and disappear. You can do that with .hide() and .show(). In this case you also need to remove the opacity-things and add display : none.)

Good luck!

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • It not only looks like a toy, it is a toy...
    • Zen Browser 1.20.2b by Razvan Serea Zen Browser is a privacy-focused, open-source web browser built on Mozilla Firefox, offering users a secure and customizable browsing experience. It emphasizes privacy by blocking trackers, ads, and ensuring your data isn't collected. With Zen Mods, users can enhance their browser experience with various customization options, including features like split views and vertical tabs. The browser is designed for efficiency, providing fast browsing speeds and a lightweight interface. Zen Browser prioritizes user control over the browsing experience, offering a minimal yet powerful alternative to traditional web browsers while keeping your online activity private. Zen Browser’s DRM limitation Zen Browser currently lacks support for DRM-protected content, meaning streaming services like Netflix and HBO Max are inaccessible. This is due to the absence of a Widevine license, which requires significant costs and is financially unfeasible for the developer. Additionally, applying for this license would require Zen to be part of a larger company, similar to Mozilla or Brave. Therefore, DRM-protected media won't be supported in Zen Browser for the foreseeable future. Zen Browser offers features that improve user experience, privacy, and customization: Privacy-Focused: Blocks trackers and minimizes data collection. Automatic Updates: Keeps the browser updated with security patches. Zen Mods: Customizable themes and layouts. Workspaces: Organize tabs into different workspaces. Compact Mode: Maximizes screen space by minimizing UI elements. Zen Glance: Quick website previews. Split Views: View multiple tabs in the same window. Sidebar: Access bookmarks and tools quickly. Vertical Tabs: Manage tabs vertically. Container Tabs: Separate browsing sessions. Fast Profile Switcher: Switch between profiles easily. Tab Folders: Organize tabs into folders. Customizable UI: Personalize browser interface. Security Features: Inherits Firefox’s robust security. Fast Performance: Lightweight and optimized for speed. Zen Mods Customization: Deep customization with mods. Quick Access: Easy access to favorite websites. Open Source: Built on Mozilla Firefox with community collaboration. Community-Driven: Active development and feedback from users. GitHub Repository: Contribute and review the source code. Zen Browser 1.20.2b changelog: Security Mozilla Security Advisory 2026-54 New Features Updated to Firefox 151.0.3 Boosts now support a dark mode UI based on your system dark mode setting. Fixes Fixed auto focus for new windows not working. (#12112) Fixed desktop shortcuts showing zen as 'Nightly'. (#13745) Other minor bug fixes and performance improvements. Download: Zen Browser | 89.8 MB (Open Source) Download: Zen Browser ARM64 | Other Operating Systems View: Zen Browser Home Page | Screenshots 1 | 2 | Reddit Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • (She does look suspiciously like she is AI generated to me but the message still stands) Another from "her" Facebook :
    • Looks the same as the Air, actually. Check it out in person.
    • "This transition will take several years so we shouldn't bother doing it at all" is a naive take. This is completely normal for all specifications that cross-cut software, hardware and multiple industries. Look at the PCI specification for another example, consumers barely have PCI-E 5 yet PCI-SIG is working on PCI-E 8. AV2 will take multiple years to get adoption and even then, even a decade from now people will still have older hardware that doesn't support it. That's fine, because the savings still add up as newer devices add the hardware to deal with it. The goal is never to get 100% on the new spec overnight, but to gradually adopt it.
  • Recent Achievements

    • One Month Later
      nothanks earned a badge
      One Month Later
    • One Month Later
      B2Proxy earned a badge
      One Month Later
    • One Year In
      MadMung0 earned a badge
      One Year In
    • Week One Done
      jefred earned a badge
      Week One Done
    • Apprentice
      JoeyNeo went up a rank
      Apprentice
  • Popular Contributors

    1. 1
      +primortal
      482
    2. 2
      PsYcHoKiLLa
      232
    3. 3
      Skyfrog
      75
    4. 4
      FloatingFatMan
      65
    5. 5
      neufuse
      54
  • Tell a friend

    Love Neowin? Tell a friend!