Useful tricks and hacks for web developers – Part 3

In this blogpost, I will focus on achieving the following effect using jQuery.
- Inverse of slideUp/slideDown using jQuery
Lets imagine the following situation – You have a slide-down menu. For this you are using 2 divs(#one and #two). div#two should slide down to show it’s content, when you click once on div#one and on the second click div#two should slide up to hide the content of div#two.
screen-capture-2010-2-8-9-54-35
You can achieve the above effect using just slideUp() and slideDown() methods in jQuery or by just using on slideToggle() statement
screen-capture-2010-2-8-9-54-59

Lets add a little more to complicate this:

In terms of user experience, the slide-up and slide-down effect works just fine when the menu is within the viewing area of the browser (i.e., within the browser window boundaries). But if the menu is near the bottom boundary, the user has to scroll down to view the scroll-down menu. Addition of any additional user actions leads to confusion and poor usability for your website, especially when your web application is used widely.

To prevent this we have to detect the position of the menu and scroll it up when the menu is near the bottom of the browser window.
screen-capture-2010-2-8-9-55-30

The code below shows you how to do just that. The method newUIPos() is used to determine the positioning of the scroll-down menu content, while the jQuery animate() is used to achieve the inverse of slideUp and slideDown in jQuery
[gist id=298183]

This is just one of way of doing this, so I would be open to any comments/suggestions.
Have a great day!

Leave a Reply









FEATURED WORK
  • South Jersey
  • Sokolove
  • Gwinnett
South Jersey
This 60-second radio commercial helped to create buzz about South Jersey Healthcare's orthopedic services department.
Sokolove
This informative video helped to re-brand the company and attract more law firm partners as well as potential customers.
Gwinnett
This Atlanta-based hospital system received a unique brand identity that helped it to stand out from the competition.
SERVICE FEATURE
 
The MoveTM Process
Consolidate your agency, data and call center services with one partner, in one physical location
SOCIAL MEDIA
RECENT TWEETS