scrollToElement fails when element has position of 0 #127

wants to merge 1 commit into


None yet
3 participants

Found an issue where if you are trying to use scrollToElement with an element that is positioned at either top 0 or left 0, jscrollpane fails to scroll to that element.

Checking if a variable is undefined using a regular
is generally unsafe, especially when you're dealing with coordinates.
Since you potentially run into the issue of
variable = 0

Just stumbled across this issue myself in v.2.0.14 and patched a fix using the following code for both destX and destY...

                    if (!isNaN(destX)) {
                        scrollToY(destX, animate);

Good work @ksykulev



ksykulev replied Jul 16, 2013

Awesome. Thanks a lot for your support!

If you solved it using isNaN already. You can just close this issue.

If you want to merge it into the master branch on your repository just go to your terminal and type in
$ git pull master
That will pull in my changes. Then just push origin master if you are satisfied with how it works.



vitch commented Jul 20, 2013

Sorry for not managing to look at this pull request for so long! It sounds valid to me although I think I prefer the isNaN approach suggested by @nmiddleweek...

Can you submit a pull request for that please? Also updating the last updated date in the comments at the top and generating a new minified version with yui compressor? (sorry the process is so manual - I haven't had any time to update this project to use grunt and make it easy to share the publishing process)


nmiddleweek commented Jul 23, 2013

Yup, sure, I'll create a pull request... Cheers guys.


vitch commented Jul 30, 2013

Fixed in #244 :)

vitch closed this Jul 30, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment