iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (35)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

November 20, 2008
Poll: Do you use an editorial calendar in your Web design work?
About
 
November 19, 2008
SEO Reports - Keyword phrases are important
About
 
November 19, 2008
Make Your Site An iPhone App
Hot Wired
 
November 19, 2008
Let My Maps Be Your Geo Database
Hot Wired
 
November 19, 2008
Revamped CitySearch Makes Facebook Connect Look Useful
Hot Wired
 
November 19, 2008
Hacking JavaScript for Fun and Profit: Part II
SitePoint
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /HTML /DHTML

DHTML Gliding Menu Navigation Bar 

  Views:    9404
  Votes:    2
by Eddie Traversa 4/30/04 Rating: 

Synopsis:

This little script was inspired by a flash navigation effect I saw some time ago. I wondered if I could do the same thing in DHTML and overall I am happy with the outcome.
Pages: firstback2 3 4 forwardlast
The Article

Essentially, the script works by capturing a links current position and then animating an element towards that link. When you have a few links in the page, the overall effect is one of a gliding or fluid motion rollover.

The first thing we need to do is create a series of variables to use later on in scripts. It is important to note that an alternate approach could be employed here, where the variables become arguments of the function and are set at the event handler point. This would allow the user to set different speeds or different offsets at each link. However, in most instances setting global variables as I have done below would suffice.

1. var timer1=null;

2. px = (document.getElementById) ? "px" : "";

3. var offset = 15;

4. var timerspeed = 25;

5. var decrease = 0.09;

Line 1:Creates a variable called timer1. This variable is used to help control the animation timer used in this script. It is good practice to create a global variable to control animation processes because not only does this give you better control over terminating the animation process, but in scripts that are more complex, it helps you better track what is going on in your own scripts.

Line 2:The px variable is used to assign whether pixels are added or not. If the condition document.getElementById is met, then pixels as measurement units are added. We need to do this because if we use a XHTML DTD then the browser expects a measurement unit to be supplied. If the browser is not a standards based browser or in other words doesn't meet the document.getElementById condition, then no pixels are applied. This allows older browsers such as Netscape 4 to function properly.

Line 3:The offset variable is used to give more finite control over where the animation ends. By default an animation will always end at the top left corner position of a link element and sometimes this position may not suit. For example, we may want to have the animation end at the centre of the link element. By increasing or decreasing the offset variable, we can adjust the end position of the animation to suit.

Line 4:This variable allows us to set the timer speed of the animation. Lower numbers will result in quicker animations, higher numbers in slower animations.

Line 5:The decrease variable is used to control the deceleration of the glide effect. In most instances setting it .09 should result in a smooth animation and nice deceleration effect. But you can try setting this variable to different numbers to see what kind of results you obtain.

Pages: firstback2 3 4 forwardlast

Similar/related articles:


 
  Sponsors