question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slides going to multiple lines with variableWidth: true

See original GitHub issue

Problem

When using variableWidth: true the track width is miscalculated when one (or more) of the slides are wider than the container. This results in the track contents overflowing to multiple lines (and the slider becoming very high).

Original slick tackles this by setting the slideWidth always to 5000px when variableWidth is used (cf. https://github.com/kenwheeler/slick/blob/a2aa3fec335c50aceb58f6ef6d22df8e5f3238e1/slick/slick.js#L2081)

Example from examples

This is visible in this example, when you resize the window: https://react-slick.neostack.com/docs/example/variable-width

screen shot 2018-05-23 at 14 59 38

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:17
  • Comments:20

github_iconTop GitHub Comments

77reactions
juanigallocommented, Dec 21, 2018

It’s a workaround but adding

display: flex to slick-track class seems to fix this issue

5reactions
aripekkakocommented, Jun 11, 2018

Hi @lorenzos, I discussed the reasoning for this fix in this Twitter thread https://twitter.com/APKoponen/status/1002111012059930624, but I’ll reiterate it here.

The original slick.js library had a more “robust” implementation for calculating the width of the variable width slides, but it was removed here as it had multiple issues. Not using a fixed value is likely to cause similar issues also with this react implementation.

The fixes this issue for 90% of the cases and is a much better option than the current broken behavior. Also, it is only a small, 1 line change in the code, which is easy to review. As you might have noticed, the contributors & owners of this library are quite busy so I’ll settle with this fix, if we could get even it to be merged.

If someone is interested in creating a better solution and thoroughly testing it with multiple corner cases they are free to do it, but I would like to see this first fix merged first and not wait for something that is quite likely not to happen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Slides going to multiple lines with variableWidth: true -
Problem. When using variableWidth: true the track width is miscalculated when one (or more) of the slides are wider than the container.
Read more >
Slick - slides jump with centerMode and variable width
I resolved this issue with a fixed width on all slide with .slick-slide { width:200px; }. and variableWidth: true. I also left centerMode...
Read more >
Multiple Rows - React Slick Documentation - neostack
The last react carousel you will ever need.
Read more >
slick variable width - CodePen
slick variable width · vicpantoja. Follow. Love Run. Pen Editor Menu. Settings ... <p>Text number 2</p>. 10. </div>. 11. <div class="box">.
Read more >
variableWidth doesn't display right [#2490528] | Drupal.org
firstly.. I love slick slider and your (gausarts) great work on that implementation I've done my slick slideshow with thumbslider described ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found