OZONE Asylum
Forums
DHTML/Javascript
Jquery { trying to use scroll for simple bottom nav idea, but having issues }
This page's ID:
31583
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
I had an idea for my website to have a bottom navigation that is always at the bottom until a certain point (990 from top for testing) and then it scrolls back up, as the user is scrolling the page. I have that part working when scrolling down the page!! But if the user scrolls back up and the nav hits 990 again it needs to go back into its fixed poistion at the bottom of the page, that is not working. Heres my code, any ideas of what I am doing wrong? [code]<script language="javascript" type="text/javascript" src="includes/js/jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(window).scroll(function () { var theHeight = $("#wrapper").height(); var p = $("#bottomNavWrap"); var position = p.position(); var top = position.top; $("#test").text( "left: " + position.left + ", top: " + position.top + ", Height: " + theHeight); if (top > 990){$("#bottomNavWrap").css({'position' : 'relative', 'bottom' : '0'});} else if (top < 990){$("#bottomNavWrap").css({'position' : 'fixed', 'bottom' : '10px'});} }); }); </script>[/code] If you see the line ([code]$("#test").text( "left: " + position.left + ", top: " + position.top + ", Height: " + theHeight);[/code]) This works all of the time if I comment out the if statement below it. No matter what I will get a reading. But if I uncomment the if statement and scroll down the page after the first condition sets I don't get a reading anymore. Its almost like after I set the css of the bottomNavWrap div the scroll function is stopped and not watching anymore. Any suggestions?
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »