360-Image-Slider icon indicating copy to clipboard operation
360-Image-Slider copied to clipboard

A bit clunky on right to left drag with few images

Open Laz75 opened this issue 10 years ago • 0 comments

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())); }

Laz75 avatar Aug 27 '14 09:08 Laz75