Home › Forums › JavaScript › Slideshow not working in toggle tabs
- This topic is empty.
-
AuthorPosts
-
January 21, 2013 at 4:16 pm #42154
Historical Forums User
ParticipantHi guys,
Please take a look at a site I’m developing, you will see I am making use of the slideshow plugin flexslider. You will also see that the site has multiple tabs. If you look at the news section you will see the articles each have a slideshow, these work fine when the tab is open by default, but if the article tab is closed by default and then opened, then the slideshow images are all small and not working correctly. Any help?
Many thanks,
AaronJanuary 21, 2013 at 4:59 pm #121767Chris Coyier
KeymasterWhat you might want to try is to wait to initialize the slider until after the window is loaded. It looks like the widths of the list items in the slider are programmatically calculated. That calculation could be wrong if the image isn’t done loading yet. So it’s best to wait until it is loaded.
$(window).load(function() {
// load slider here
});Or, make sure all those images have proper width/height attributes on them so the slider list items can be calculated correctly right away.
January 22, 2013 at 4:31 pm #121935Historical Forums User
ParticipantThe problem is it’s a responsive layout, so there is no fixed width on the images only max-width: 100%
January 26, 2013 at 6:48 am #122384hackerone
MemberHey Aaron,
when i checked your website, you seemed to have removed the slider. so can’t really pinpoint the problem.
but what i think is happening is, when the tabs are hidden, the images inside it don’t get loaded
so the image widths wouldn’t be calculated on windows load and hence the slide show doesn’t work
but when the tab is open, the images would be loaded on windows load.
what i would suggest is you can initialize the slide show once the tab is opened or use a script which checks if all the images inside the dom are loaded before firing a callback.
i’ve made one for my personal site, you can use that if it fits your bill,
March 11, 2013 at 5:27 am #127727geoffreyrose
MemberHey Aaron,
Your problem might be the fact your using max-width: 100%.
I have only had problems declaring max-width: 100%. Instead try doing something like this..class {
max-width: 960px; /** Put in whatever is the largest width it wil ever need to be **/
width: 100%;
} -
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.