Difference between revisions of "Template:AUC TURKEY"
Line 56: | Line 56: | ||
<script> | <script> | ||
// Calling the function | // Calling the function | ||
− | $(function(){ | + | $(function() { |
− | + | // get the top offset of the menu element var | |
− | + | menuTop = $("#menu").offset().top; | |
− | + | // trigger the function when the windows scroll | |
− | + | $(window).scroll(function() { | |
− | + | // get total scrolling | |
− | + | var htmlTop = $(window).scrollTop(); | |
− | + | // check if the scrolling is less than top offset of menu | |
− | + | // then stick the menu on top by adding the stickyCssClass | |
− | + | // If not then set the menu at it's default position by removing the stickyCssClass | |
− | + | if (htmlTop > menuTop) { | |
− | + | // add the class to stick on top | |
− | + | $("#menu").addClass(".fixedMenu"); | |
− | + | $("#contentContainer").addClass(".shiftContent"); | |
− | + | } else { | |
− | + | // remove the stick on top class | |
− | + | $("#menu").removeClass(".fixedMenu"); | |
− | + | $("#contentContainer").removeClass(".shiftContent"); | |
− | + | } | |
− | + | }); | |
+ | }); | ||
</script> | </script> | ||
<div class="menu"> | <div class="menu"> |
Revision as of 11:44, 23 June 2015