Home arrow JavaScript arrow Page 3 - Finishing a Collapsible Navigation Bar with CSS and JavaScript
JAVASCRIPT

Finishing a Collapsible Navigation Bar with CSS and JavaScript


Welcome to the final tutorial of a series on building a dynamic navigation bar with CSS and JavaScript. This series of articles steps you through the development of a dynamic navigational system. We use the combined functionality of the popular Prototype and Scriptaculous JavaScript libraries, without compromising overall accessibility.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
October 13, 2009
TABLE OF CONTENTS:
  1. · Finishing a Collapsible Navigation Bar with CSS and JavaScript
  2. · The scrollable bar’s structural markup
  3. · Building a glitch-free scrollable navigation bar: using the “blind” animation effect of Scriptaculous
  4. · The scrollable navigation bar's full source code

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Finishing a Collapsible Navigation Bar with CSS and JavaScript - Building a glitch-free scrollable navigation bar: using the “blind” animation effect of Scriptaculous
(Page 3 of 4 )

As I explained in the previous section, my plan consists essentially of animating the navigation bar that was coded before by way of a smooth scrolling effect. In simple words, each time a user clicks on the corresponding switcher, the bar will be removed and displayed alternately on the web page, and this process will be animated by scrolling. Pretty simple to understand, right?

However, in order to apply this scrolling effect to the navigation bar, I’m going to employ a brand new method bundled with the Scriptaculous library, called “blind.” This effect can scroll not only the selected web page element, but all of its additional contents.

Given that, here’s the short JavaScript snippet that performs the scroll animation:

// display/hide navigation bar


function toggleNavBar(){

new Effect.toggle('navbar','blind');

}


// initialize navigation bar switcher


function initializeElement(){

Event.observe($('switcher'),'click',toggleNavBar,false);

}

Event.observe(window,'load',initializeElement,false);

As I said before, in this particular case I used the “blind” animation effect provided by Scriptaculous to scroll the corresponding navigation bar up and down, each time the switcher is clicked. Of course, the reason for utilizing this effect is that it’ll animate the navigational bar along with all of its sub elements.

So far, so good. At this stage, I already showed you how to use a few intuitive methods that come included with Prototype and Scriptaculous to make this navigational bar completely scrollable. Thus, assuming that you grasped the logic behind this process, it’s time to build a new (X)HTML file that includes the previous JavaScript code, along with the structural markup that you saw in the first section, thus completing the development of this scrollable bar.

The complete signature of the aforementioned (X)HTML file will be shown in the section to come, so click on the link below and keep reading.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials