cialis online pharmacy generic xenical cheap cialis online cialis generic viagra online in canada buy cheap levitra online cialis without a perscription order viagra uk no prescription flagyl cheap generic levitra buying viagra in the uk cheap viagra approved cialis deltasone online buy viagra online without prescription non prescription cialis buy orlistat uk buy cialis in india prednisone 60 mg female viagra online buy viagra without prescription celebrex prescriptions buy cialis canada best prices viagra alternative to prednisone cheapest generic levitra levitra 5mg cheap viagra cialis on line buy xenical without prescription online accutane canadian health care prednisone no prescreption viagra online generic female viagra europe buy cialis low price cheap india viagra

How To Contain A Menu Sidebar Using MooTools

Today’s featured MooTools snippet comes from Joel Lipman. It’s a little piece of code that you can use to contain the menu sidebar if you happen to have a dynamic content page.

Joel’s site consists of a content page that changes its height often. He needed a way to prevent the menu sidebar to overlap the header and the footer; hence he came up with the set of code below which he also decided to share with the rest of us.

window.addEvent('scroll', function() {

 var menu_highest_top = $('jdo_marker_table').getCoordinates().top;
 var menu_height = $('jdo_actions').getCoordinates().height;
 var component_top = $('jdo_overall').getCoordinates().top;
 var component_height = $('jdo_overall').getCoordinates().height;
 var match_lowest_y = component_height + component_top - menu_height;
 var match_highest_y = menu_highest_top + (component_top - menu_highest_top);

 if( window.XMLHttpRequest ) {
 if (document.documentElement.scrollTop > menu_highest_top || self.pageYOffset > menu_highest_top) {
 if (document.documentElement.scrollTop > match_lowest_y || self.pageYOffset > match_lowest_y) {
 $('jdo_actions').style.position = 'absolute';
 $('jdo_actions').style.top = match_lowest_y + 'px';
 } else {
 $('jdo_actions').style.position = 'fixed';
 $('jdo_actions').style.top = '5px';
 }
 } else {
 $('jdo_actions').style.position = 'relative';
 $('jdo_actions').style.top = '0px';
 }
 }
});
// still to do: smoothscroll? if already overlaps then flicks up   

If you happen to have a better idea or approach, feel free to let him know about it by hitting him up here.

 

Related Posts

Adding Instagram Badges to Your WordPress Profile

How to Create a Custom WordPress Registration Form with Flat UI

How to Create A Basic Hipster-Style Layout

How to Style Nav Links Using Floats With HTML5 and CSS3