Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think Andrew was on the right track with regards to setting the height of the <code>#wrapper</code> div. As he pointed out that,</p> <pre><code>that.maxScrollY = that.wrapperH - that.scrollerH; </code></pre> <p>Normally, this would work. But now that you've changed your <code>#content</code> to <code>position: fixed</code>, the wrapper element is no longer "wrapping" your content, thus <code>that.wrapperH</code> has a value of 0, things break.</p> <p><em><strong>Disclaimer: I did not go through the entire script so I may be wrong here</em></strong></p> <p>When manually setting a height to <code>#wrapper</code>, say <code>500px</code>, it becomes,</p> <pre><code>that.maxScrollY = 500 - that.scrollerH; </code></pre> <p>The folly here is that when there's a lot of content and the window is small, <code>that.scrollerH</code> is relatively close in value to 500, say <code>700px</code>. The difference of the two would be <code>200px</code>, so you can only scroll 200 pixels, thus giving the appearance that it is frozen. This boils down to how you set that <code>maxScrollY</code> value. </p> <p><em><strong>Solution (for Chrome browser at least):</em></strong></p> <p>Since <code>#wrapper</code> effectively contains no content, we cannot use it in the calculations. Now we are left with the only thing that we can reliably get these dimensions from, <code>#content</code>. In this particular case, it appears that using the content element's <code>scrollHeight</code> yield what we want. This is most likely the one that has the expected behavior,</p> <pre><code>that.maxScrollY = that.scrollerH - that.scroller.scrollHeight; </code></pre> <p><code>scrollerH</code> is the <code>offsetHeight</code>, which is roughly the height of what you see in the window. <code>scroller.scrollHeight</code> is the height that's considered scrollable. When the content does not exceed the length of the page, they are roughly equivalent to one another. That means no scroll. When there are a lot of content, the difference of these two values is the amount of scroll you need.</p> <p>There is still a minor bug, and this looks like it's already there. When you have a lot of content, the last few elements are covered up by the bar when scrolled to the bottom. To fix this, you can set an offset such as,</p> <pre><code>that.maxScrollY = that.scrollerH - that.scroller.scrollHeight - 75; </code></pre> <p>The number 75 arbitrary. It's probably best if it's the height of the bar itself with 2 or 3 pixels for a bit of padding. Good luck!</p> <p><em>Edit:</em></p> <p>I forgot to mention last night, but here are the two sample pages that I used in trying to debug this problem.</p> <p><a href="http://www.akngo.com/stackoverflow/7026114/long.html" rel="nofollow">Long page</a><br> <a href="http://www.akngo.com/stackoverflow/7026114/short.html" rel="nofollow">Short page</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload