splide icon indicating copy to clipboard operation
splide copied to clipboard

Cannot scroll without animation

Open bonstio opened this issue 1 year ago • 0 comments

Checks

  • [X] Not a duplicate.
  • [X] Not a question, feature request, or anything other than a bug report directly related to Splide. Use Discussions for these topics: https://github.com/Splidejs/splide/discussions

Version

v4.1.3

Description

It's not possible to call scroll without invoking an animation.

Reproduction Link

No response

Steps to Reproduce

  1. Setup Splide

  2. Make a call (e.g. from the JavaScript Console) to

    splide.Components.Scroll.scroll(index, 0, true);

Since the duration param here is set to 0, there should NOT be a visible animation, yet there is.

The problem happens because of this line of code in Scroll.ts

duration = noDistance ? 0 : duration || max( abs( destination - from ) / BASE_VELOCITY, MIN_DURATION );

One fix is to explicitly check if duration has been defined:

   duration = noDistance ?
        0 : 
        (duration === undefined ? 
            max(abs(destination - from) / BASE_VELOCITY, MIN_DURATION) :
            duration);

Expected Behaviour

No scroll animation

bonstio avatar Apr 12 '24 19:04 bonstio