Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

JudeOsborn
Copy link

I noticed that when scrollable does not have a full complement of items (blank spaces) an error will be thrown when circular is turned on. I have adjusted for this error by returning an top value of 0 when there is no top value.

@alibby251
Copy link
Contributor

Hi JudeOsborn,

Any chance you could please provide a test case, where we can see a before (i.e. with the error) and after (without the error)? Also, could you please rebase this on the dev branch of jQuery Tools, and not the master as you have done here?

Thanks.

@JudeOsborn
Copy link
Author

Here's a JSFiddle that illustrates the problem:

http://jsfiddle.net/T5uvu/1/

You'll see that the problem only surfaces when setting "circular" to true. If you view the "result" frame's console you'll see the message "Uncaught TypeError: Cannot read property 'top' of null". I don't have a CDN version of my fixed version, but all I'm doing is handling a null position().

@Mairu
Copy link

Mairu commented Jun 18, 2013

If item.position() is null, the else part will throw the same error and so should also be modified to be correct when vertical is false.

@JudeOsborn
Copy link
Author

Yes, good point. I fixed that and simplified the line of code a tiny bit.

@Mairu
Copy link

Mairu commented Jun 19, 2013

But props should be an object: 0 != {top: 0} or {left: 0}, otherwise the animate call should fail or at least would do nothing.

var dir = vertical ? 'top' : 'left',
    props = {},
    pos = item.position();
props[dir] = pos ? -pos[dir] : 0;

If no animation is done when no position is available return self; would be best.

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.

3 participants