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

Center mode does not work as expected when slidesToShow is an even number #2416

Open
jumodada opened this issue Jan 2, 2025 · 1 comment

Comments

@jumodada
Copy link

jumodada commented Jan 2, 2025

version: 0.30.3

If slidesToShow is an even number, the situation where the image is centered will not work. Is this by design or a bug?

import React, { Component } from "react";
import Slider from "react-slick";

function CenterMode() {
  const settings = {
    className: "center",
    centerMode: true,
    infinite: true,
    centerPadding: "60px",
    slidesToShow: 4,
    speed: 500
  };
  return (
    <div className="slider-container">
      <Slider {...settings}>
        <div>
          <h3>1</h3>
        </div>
        <div>
          <h3>2</h3>
        </div>
        <div>
          <h3>3</h3>
        </div>
        <div>
          <h3>4</h3>
        </div>
        <div>
          <h3>5</h3>
        </div>
        <div>
          <h3>6</h3>
        </div>
      </Slider>
    </div>
  );
}

export default CenterMode;

@utgupta27
Copy link

This worked for me
const settings = { className: "center", centerMode: true, infinite: true, slidesToShow: 1, speed: 500, autoplay: true, autoplaySpeed: 2000, pauseOnHover: true, rows: 1, slidesPerRow: 1, variableWidth: true, variableHeight: true, };

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

2 participants