Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Uncaught Error for negative scroll height. #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JangoSteve
Copy link

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:

Uncaught Error: Syntax error, unrecognized expression: (-1) 

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant