10

I tried to integrate wootheme's Flexslider on my site and it looks/works great except for when it is loading.

When you refresh the page with the slider, before flexslider loads (about 1 second) the first slide appears very big and flashes to black then dissapears and then the carousel appears.

I think the image is loading faster than the jquery? How can I hide the image unti jquery loads (like on the demo website, even if i refresh 3 billion times, the problem is never repeated on their website, it all loads gracefully! - http://flexslider.woothemes.com/carousel-min-max.html )

I loaded the flexlisder.js right after jquery and copied the same html code from the demo (to match the .css file that is also loaded. And here is the init code I am using - from the demo site also:

$(document).ready(function() {

  $('.flexslider').flexslider({
    animation: "slide",
    animationLoop: false,
    itemWidth: 210,
    itemMargin: 5,
    minItems: 2,
    maxItems: 4
  });
});
Alex Kulinkovich
  • 4,408
  • 15
  • 46
  • 50
user1945912
  • 597
  • 3
  • 9
  • 19

6 Answers6

22

You need to deal with the callback functions for the plugin you are using hide all the images from CSS by using a class let's say flexImages

$(document).ready(function() {

  $('.flexslider').flexslider({
    animation: "slide",
    animationLoop: false,
    itemWidth: 210,
    itemMargin: 5,
    minItems: 2,
    maxItems: 4, 
    start: function(){
         $('.flexImages').show(); 
    },
  });
});
Seder
  • 2,735
  • 2
  • 22
  • 43
  • 1
    Thank you so much! that did the trick! Woothemes didn't mention doing that, yet their demos work perfect regardless! – user1945912 Feb 01 '13 at 22:21
  • 2
    I am glad it helped, but my advice to you is when you face such problems with plugins or such stuff read about their callbacks it really will help :) – Seder Feb 01 '13 at 22:23
6

Set the default style for "display" to "none". using show() will change this style value.

Steve H.
  • 6,912
  • 2
  • 30
  • 49