scrollToElement fails when element has position of 0 #127

Closed
wants to merge 1 commit into
from

Conversation

Projects
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
'if(variable)'
is generally unsafe, especially when you're dealing with coordinates.
Since you potentially run into the issue of
variable = 0
if(variable)

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

Nick

Owner

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 https://github.com/ksykulev/jScrollPane.git master
That will pull in my changes. Then just push origin master if you are satisfied with how it works.

Thanks.
-Konstantin

Owner

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)

Contributor

nmiddleweek commented Jul 23, 2013

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

Owner

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