-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Not working on Bootstrap's modal or tab #619
Comments
You need to call $('.your-selector)[0].slick.setPosition() when it appears |
The resize() seems to work for me too from this issue 187 but it doesn't work with multiple sliders/modals. I also tried t he .slick.setPosition() and it's the same thing. It seems like only one of the modal window works and it's the first modal that you click. I have this code:
and Fiddle - http://jsfiddle.net/vanduzled/nv446jgm/2/ |
I had the same problem, not with modals but with tabs though, and came accross this solution on google groups you might find useful. (https://groups.google.com/forum/#!topic/twitter-bootstrap-stackoverflow/0Aqzs5s_hEY) "The Cause: ... the problem is caused by the fact that Bootstrap uses .tab-content > .tab-pane, .pill-content > .pill-pane {
display: none; /* this is the problem */
} This causes Highcharts not able to get the expected width to create the chart. This would happen to other tools using the same approach to have DOM elements hidden or disappeared. A Pure CSS Solution: Alternatively, we can achieve the hidden effect using height: 0; overflow-y: hidden, this way the hidden tab panes are still in place and having valid width: /* bootstrap hack: fix content width inside hidden tabs */
.tab-content > .tab-pane,
.pill-content > .pill-pane {
display: block; /* undo display:none */
height: 0; /* height:0 is also invisible */
overflow-y: hidden; /* no-overflow */
}
.tab-content > .active,
.pill-content > .active {
height: auto; /* let the content decide it */
} /* bootstrap hack end */ This solution is seamless, so you no longer have to worry whether the chart is inside a tab-pane or not. And it's efficient as it fixes the width issue in the first place, thus there's no need to fix the width issue afterward via resize/redraw/reflow using javascript code. Demo: Before: vs After: Worked like a charm in my case. |
thanks tpiechota - your suggestion is brilliant! In my case I had slick sliders embedded in a Foundation 5 accordion, and your method of using the height to control the visibility worked like a CHAMP! Thank you! |
@tpiechota - what a beautiful solution. I'd spent hours battling with JS fixes and hacks, and your CSS solution is awesome. Thank you, thank you. |
Yeah resize() on shown works, but it's causing a considerably laggy feel when the slider jumps into view on modals. |
@tpiechota great solution, thanks! |
@tpiechota You saved my day! |
I would add overflow-y: visible; if your arrows are outside of the slider they won't show up with this hack.
|
Bootstrap fires an event when the modal is 'shown'.
Which enables you to hook into the flow and re-render slick. |
When I tried this inside a tab or a modal on Twitter Bootstrap, the carousel doesn't appear. As if it seem like it has a zero height. When I click on next photo using the bullets or wait for awhile to auto scroll, the photo appear.
Here is a JS Fillde of the problem on Modal - http://jsfiddle.net/vanduzled/s18ce5gr/
Anyone can help?
thanks!
The text was updated successfully, but these errors were encountered: