react-slick icon indicating copy to clipboard operation
react-slick copied to clipboard

variableWidth: true, infinite: false not disabling the next arrow button when the last element enters the viewport

Open rsiuli001 opened this issue 10 months ago • 3 comments

Issue:

When variableWidth is "true" and infinite is set to "false", next button does not get disabled when the last element enters the viewport. It keeps on scrolling leaving a whitespace after the last element.

Also is there any easier way to calculate "slidesToShow" variable? Max possible number of elements should be present in the screen and "slidesToScroll" should be "slidesToShow - 1" or 1 whichever is the higher.

 const settings: Settings = {
    className: "slider variable-width",
    dots: false,
    infinite: false,
    centerMode: false,
    variableWidth: true,
    slidesToShow: numSlides,
    slidesToScroll: numSlides,
  };
<Slider ref={sliderRef} {...settings}>
          {data.map((el, i) => {
            return (
              <div
                id={`element-${i}`}
                className="whitespace-nowrap p-2 w-auto"
                key={i}
              >
                {el}
              </div>
            );
          })}
</Slider>
Screenshot 2024-04-09 at 1 54 58 AM

Code sandbox: https://codesandbox.io/embed/ncsf68?view=Editor+%2B+Preview&module=%2Findex.js

rsiuli001 avatar Apr 08 '24 20:04 rsiuli001

Hi! I've been dealing with the same issue and couldn't find a workaround.

joae avatar Apr 12 '24 14:04 joae

Same here guys, I couldn't find a workaround

EL-MEHDI-ESSAADI avatar Apr 30 '24 11:04 EL-MEHDI-ESSAADI

I have same issue; I have found how to deal with this issue.

maodelife avatar Aug 08 '24 08:08 maodelife