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

slide width bug when upgrading to 0.14

Open aribronstein opened this issue 10 years ago • 18 comments

I upgraded to 0.14 on my development environment today and my slides started getting very large width values and not showing multiple slides at once.

my settings:

settings = {
      dots: false,
      infinite: false,
      speed: 500,
      slidesToShow: 6,
      slidesToScroll: 6,
      waitForAnimate: false,
      // Resolutions
      responsive: [{
        breakpoint: 1510,
        settings: {
          slidesToShow: 6,
          slidesToScroll: 6
        }
      }, {
        breakpoint: 1025,
        settings: {
          slidesToShow: 4,
          slidesToScroll: 4
        }
      }, {
        breakpoint: 610,
        settings: {
          slidesToShow: 3,
          slidesToScroll: 3
        }
      }, {
        breakpoint: 480,
        settings: {
          slidesToShow: 2,
          slidesToScroll: 2
        }
      }, {
        breakpoint: 321,
        settings: {
          slidesToShow: 2,
          slidesToScroll: 2
        }
      }]
    };

aribronstein avatar Sep 08 '16 08:09 aribronstein

Out of curiosity, are you using a combination of flexbox and percentage widths in the parent nodes are you? I'm trying to constrain the aspect ratio of a div within a flexbox'd node and then embedding the slider into that and experiencing the giant images.

Ignoring the recalculation badtimes i've got screen resize, it feels like something isn't able to correctly calculate it's width - if i hard code px values it all works fine, but that kinda defeats the point of what i'm trying to do!

I'm getting around it atm by positioning absolutely and setting top, right, bottom and left to 0; feels a bit hacky tho.

ryjoyce avatar Sep 08 '16 12:09 ryjoyce

I'm using Bootstrap 3 so the slide elements are each a percentage width in the css I am not using flex in connection to slick. I am using flex in an sibling to the slider but less relevant.

aribronstein avatar Sep 08 '16 12:09 aribronstein

If you are using flex property, add the below in your css

* {
  min-height: 0;
  min-width: 0;
}

akiran avatar Sep 08 '16 13:09 akiran

I couldn't replicate this issue with the given settings

Can you replicate this issue with jsfiddle https://jsfiddle.net/kirana/20bumb4g/

akiran avatar Sep 08 '16 17:09 akiran

Here is the problem reproduced it might need a resize of the preview pane to trigger https://jsfiddle.net/9sw8hqoo/1/

Here is the same jsfiddle with v0.13.6 and it is working great https://jsfiddle.net/0adgL6aq/1/

aribronstein avatar Sep 08 '16 17:09 aribronstein

@akiran I am also seeing this issue. I cloned your example and changed it to 2 slides to show.

Reproduceable steps:

  • https://jsfiddle.net/creatifyme/20bumb4g/1245/
  • resize the rendered slider panel width
  • example http://i.imgur.com/cvagDL8.gifv

creatifyme avatar Sep 08 '16 17:09 creatifyme

Im getting the same issue after updating, it was working perfect before 0.14. If it helps I have the slider in a column using React Flexbox Grid and have tried adding the CSS as mentioned by @akiran but that didn't make any difference for me.

benbxyz avatar Sep 08 '16 18:09 benbxyz

I am also seeing the same issue. On scroll in a parent div the translation calculation I am seeing some really interesting numbers. screen shot 2016-09-08 at 3 18 14 pm

bradbirnbaum avatar Sep 08 '16 19:09 bradbirnbaum

@Josh-ES People started facing some issues after we merged vertical PR Do you have any insights ?

akiran avatar Sep 09 '16 13:09 akiran

@akiran I have a rough idea of what might be causing this, I'll investigate further and submit a pull request in a few. Bear with me!

EDIT: see PR #469. I believe I've solved it, but I'll take another look if this issue, or indeed any other issue, is still present.

Josh-ES avatar Sep 09 '16 14:09 Josh-ES

Can you test out 0.14.2

akiran avatar Sep 11 '16 11:09 akiran

looks great, thanks!

aribronstein avatar Sep 11 '16 11:09 aribronstein

Broken for me at the moment (0.14.5)

MakarovAV avatar Nov 30 '16 14:11 MakarovAV

It seems it's a bug they didn't finish fixing. Here's a workaround that works for me - add the following to React's component that contains the react-slick:

constructor() {
      [...]
      this.onWindowResized = this.onWindowResized.bind(this);
  }

  componentDidMount() {
      window.addEventListener('resize', this.onWindowResized);
  }


  componentWillUnmount () {
      window.removeEventListener('resize', this.onWindowResized);
  }

  onWindowResized() { //add debounce for performance?
      this.forceUpdate(); //react's default forceUpdate
  }

This will effectively force React to re-render the entire component on window resize, fixing the problem.

giladbr avatar Feb 05 '17 13:02 giladbr

+1 - The demo and my own code completely break on a resize.

trekinbami avatar Feb 10 '17 13:02 trekinbami

^0.23.2 and still broken.. content is constantly growing

uragecz avatar Mar 18 '19 13:03 uragecz

UPDATE: it can't be surrounded by flex.. When i removed flex around now it works

uragecz avatar Mar 18 '19 13:03 uragecz

This is still happening. Any updates on fixes or workarounds for this problem? My slider is inside of a div element with a box display but the parent of this div element has display flex set. The flex is breaking the slider.

magiclinks-cpark avatar Aug 09 '21 21:08 magiclinks-cpark