Slider outgrows container (and continues growing) when number of slides reaches three

Description:

Slider outgrows container (and continues growing) when number of slides reaches three

Step-by-step reproduction instructions:

  1. Create a page or post
  2. Add a Cwicly slider
  3. Add a slide with a background image
  4. Duplicate that slide two times

Note: I have changed the relative styles for my post content per this thread in case it is relevant:

Screenshots, screen recording, code snippet

https://h-vd.io/Xo9VA9DP?

Watch Video

Environment info

  • WordPress version: 6.2
  • Gutenberg Plugin version: -
  • Cwicly Plugin version: 1.2.9.5.7
  • Cwicly Theme version: child theme on 1.0.3

@smontreuil, does this happen when you set an explicit height on the slides themselves or does that constrain them?

I’m wondering if it is happening because you have set an explicit height on the Slider container, but the width of the Slides is dynamically set by the layout (default being 3 per view) and therefore the image dimensions may not fit within that layout if the aspect ratio doesn’t match the width of the slider divided by 3 and the height of the slider.

If you need an explicit height, you could make the images use object-fit cover and then allow them to dynamically scale to fit within the available width and height of the slider - that may solve it.

1 Like

I don’t know how to do that :roll_eyes:

I am having the same issue you can give width 100% to the parent item or slider, it solved my issue.

Yes, I have done this and it is still outgrowing my screen.

I figured out what you meant by 'object-fit cover and I actually already had this selected because my images are background.

@Louis do you see anything I could do here to fix this issue?

Set overflow to hidden. Should solve it (as a workaround).

So, reviewing your screen recording, everything is growing (i.e. width is being pushed) as the slider is growing, including the paragraphs underneath the slider, which suggests it could be a problem with your post content styles not enforcing the width.

As a quick test I replicated all of the steps you did identically with the Slider and did not experience the problem, so I recommend firstly checking that you definitely set the max-width on all elements of the post content and not just the width (for example).

I have been working on this page a little more and have found that the slider only outgrows the page when the div that contains my post content block is set to column / center. If I turn off ‘center’ then the slider stops outgrowing the page.

Hi @smontreuil try adding a div in each side and add an image block. So not a background image but an <img>
Screenshot 2023-04-03 at 13.48.13

1 Like

Thank you for the suggestion @hopscotch , I typically use background images for scenarios like this so that the images will always appear consistent size-wise in relation to each other. If I understand correctly, placing an image block inside the div would allow for the possibility that each image could possibly display as a different size, no?

Turning of the ‘center’ formatting on the div fixed the issue.

@smontreuil you have more control with an inline tag. But say I had a slider with text centred with a CTA then I would use a background image. But you can do either or.

for me a solution was to gibve some kind of max-width, height, width values to the slider element…you must play around a bit to find a way…

I have problems almost every time I add a slider. It used to be the slider would grow infinitely when I set it to scroll vertically, so I avoided vertical sliders. Today I added a slider set to horizontal and it started growing uncontrollably too. It’s the only block that consistently gives me problems, so I think @Louis should take a closer look at it because it seems finicky.

Edit: One thing that seems to contribute to this is of you remove the gap value. If you explicitly set it to zero, it seems to help. I’ll have to experiment a little more, but that seemed to help for now.

Hi @msguerra74,

Sorry to hear you’re experiencing trouble with the Slider block.

Could you possibly provide more detail on what lead the slider to grow infinitely?
I ask as removing the gap value didn’t have any particular effect on my end.

Thank you in advance.

Hi @msguerra74,

We were eventually able to reproduce this issue on our end, which should now be fixed wit 1.4 :

Kindly let me know if this is the case on your end.
Thank you in advance.

Great, thank you! I haven’t had time to look into it further since I posted, but it’s good to know it’s been identified and fixed :slightly_smiling_face: