Skip to content

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

Description

@Laz75

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions