Topic: Jquery { trying to use scroll for simple bottom nav idea, but having issues } (Page 1 of 1) |
|
---|---|
Obsessive-Compulsive (I) Inmate From: purgatory |
posted 01-09-2010 04:20
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. 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: $("#test").text( "left: " + position.left + ", top: " + position.top + ", Height: " + theHeight); ) 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. |
Obsessive-Compulsive (I) Inmate From: purgatory |
posted 01-12-2010 21:47
Can anyone help Please? |
Paranoid (IV) Inmate From: Norway |
posted 01-13-2010 00:51
It would help to see a live example to see your CSS and markup. |
Obsessive-Compulsive (I) Inmate From: purgatory |
posted 01-22-2010 01:44
what I am trying to do is that when the user scrolls down the page is the nav gets to a certain point we no longer use the bottom 0 style. check out the link |
Nervous Wreck (II) Inmate From: |
posted 05-31-2011 11:03
Edit TP: spam removed
|