Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation Loading bar help!

    Hi everyone,

    I am having trouble getting a loading bar to appear from my javascript.

    I have the following code in place

    Code:
    $(document).ready(function(){
     $(window).scroll(function(){
    
      var h = $('#footer').height();
      var y = $(window).scrollTop();
      if( y > (h*0) && y < (h*1.0) ){
    
    	  $('#loading').fadeIn("slow");
    	   $('#loading').delay(10000).fadeOut();
    
       $("#portfolios").delay(1000).fadeIn("slow");
      
      }
     });
    })
    I have it so when the user reacher the 'footer' div of the page, new posts appear which are contained in the 'portfolios' container div. They appear fine but no loading bar appears...

    The loading bar 'gif' is in the 'loading div id'.

    There is a 'display:none;' in the css on the loading div and the portfolios div.

    Any reason why the 'loading' div doesn't display but the portfolios does?

    I want the loading gif to show whilst the 'portfolios' is loading basically when the user hits the bottom of the page.

    Any help would be appreciated!

    Thank you!

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,105
    Thanks
    23
    Thanked 594 Times in 593 Posts
    This line if( y > (h*0) && y < (h*1.0) ){ says; When the scrollTop is greater then zero [that is not at the top of the page] AND it's less then the height of the footer [and that's your error]

    The bottom of the page occurs when the window height - footer height is reached. You need to rethink y < (h*1.0).

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Location
    New York, NY
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    hats off to 'sunfighter'

    hats off to 'sunfighter'
    <<
    Thanked 118 Times in 118 Posts
    >>

    and you're a 'regular coder'??

    something wrong with THAT algorithm!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •