baianat / hooper

🎠 A customizable accessible carousel slider optimized for Vue
https://baianat.github.io/hooper/
MIT License
716 stars 132 forks source link

Slide width is 0px #189

Open simondrabble opened 4 years ago

simondrabble commented 4 years ago

Describe the bug The width of each slide is 0px, resulting in all slides being squashed on top of each other.

To Reproduce Steps to reproduce the behavior:

  1. Follow "Getting Started" instructions.

Expected behavior Slides display as in examples.

Screenshots

image image

Desktop (please complete the following information):

Additional context I'm also using bootstrap, with all page content inside a bootstrap container.

lowercasename commented 4 years ago

I've got this same issue too, but I'm not using Bootstrap. It doesn't seem to make a difference what content I put in the slides - images or a single line of text - nor how many slides I ask Hooper to show; all the slides are always squashed together with width: 0.

DarioCorno commented 3 years ago

Did someone find a solution for this problem? I'm having it too

cormacdoesprogramming commented 3 years ago

I've just ran into the exact same error within a project where I already had a hooper slider working in a very similar way to how I was implementing it the second time.

Anyways the cause of this issue for me was that I had the hooper component wrapped in a 'v-show'. Since the page I was working on was dynamic meaning I had a lot of v-shows and v-ifs scattered about. After switching all of the parent components to use v-if instead of v-show the hooper slider displayed properly.

Hope this helps if you need a code example please let me know!

Stampeder525 commented 3 years ago

I'm also having this issue - I'm putting the slides in a v-for. I've got a lot of slides, so I sorta need to do it this way without replicating a bunch of code, but is that going to just fundamentally break it?

srochefortNmedia commented 3 years ago

This solution should correct the problem: In your CSS:

.hooper-slide {
    min-width: 100%;
}

I tried first to put an inline style to the slide but I don't know what could be the result in all the cases, and inline style is not great at all.

StuartCreed commented 2 years ago

Hooper dynamically calculates the widths. In my case I had a carousel that was dynamically populated by a search. On page load the width was zero as there was nothing in the carousel. But on user search the carousel width did not change from zero when there were images in the carousel. I used this update method to recalculate the widths https://baianat.github.io/hooper/api.html#methods on search input. To invoke this put a ref on the hooper element e.g. called "hooper" and trigger it using $this.refs.hooper.update()

sudamonline commented 1 year ago

I found that the reason for why the width was zero was because my sider was wrapper in a boostrap grid.

image

This resulted in the width being 0. Once I removed the wrapper, it worked fine!

Hope this helps!