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

A bit clunky on right to left drag with few images #5

Open
Laz75 opened this issue Aug 27, 2014 · 0 comments
Open

A bit clunky on right to left drag with few images #5

Laz75 opened this issue Aug 27, 2014 · 0 comments

Comments

@Laz75
Copy link

Laz75 commented Aug 27, 2014

Hello, I was trying to use this great script with a lower number of images (15-20) and noticed that dragging from right to left was a bit clunky (while left to right worked beautifully.

I realized the problem was the Math.ceil used in the trackPointer function, with negative numbers it doesn't produce the expected output (this doesn't occur when you're using many more images, of course).

A simple if using Math.floor for negative numbers does the trick and everything works just fine now.

if (pointerDistance > 0) {
endFrame = currentFrame + Math.ceil((totalFrames - 1) * speedMultiplier * (pointerDistance / $container.width()));
} else {
endFrame = currentFrame + Math.floor((totalFrames - 1) * speedMultiplier * (pointerDistance / $container.width()));
}

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

No branches or pull requests

1 participant