Fixed Uncaught Error for negative scroll height. #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was having an issue where TOC was causing the following error when the scroll-height of the page was negative relative to the top of the TOC sidebar from the line changed in this PR:
At first you might think, the TOC sidebar is fixed at the top of the page, when would the relative scroll-height ever be negative?
The answer is, we have the sidebar further down the page under the heading, and it only becomes fixed when you scroll down to it, so you can scroll up above the sidebar.
But that actually doesn't matter, because this can also happen in both OSX and iOS, where the browsers have a sort of "pulling" effect at the top of the page (where you can continue scrolling up above the page and it makes it look like you're pulling against the top of the page where you can see a gray textured background), and yes JavaScript actually reports a negative scrollTop position when this happens.
In most of the browsers, this doesn't matter incredibly much, it just outputs an Uncaught Error to the console and continues working once you've gone back to a positive relative scroll position. However, for our first example, where the sidebar is further down the page, it actually causes ugly modal error popups in IE7 and IE8.
So this fixes all that.