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

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

Open
rsiuli001 opened this issue Apr 8, 2024 · 2 comments

Comments

@rsiuli001
Copy link

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

@joae
Copy link

joae commented Apr 12, 2024

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

@EL-MEHDI-ESSAADI
Copy link

Same here guys, I couldn't find a workaround

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

3 participants