Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6709421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:52:46+00:00 2026-05-26T07:52:46+00:00

I’m working on a gallery with jCarousel. I’ve created a script that loads the

  • 0

I’m working on a gallery with jCarousel.
I’ve created a script that loads the next images to the gallery each time I click on the next button from an array. Each time I click next, the next five images are loaded. It all works really great, but my problem is that I see the empty

  • before the images are loaded, so half of the animation’s duration I only see empty squares moving.
    I tried two solutions :
    1) add a delay to the animation – after the

  • items are added to the carousel, add a wait of a second or two – which didn’t work for me, because it seems that part of the animation is to turn the newely added images to visible, so if I add a delay animation function, it does the exact same things (show empty squares for a moment)…

    The interesting thing is that if I add an alert, when I dismiss it the images are already loaded and the animation is perfect – as if the code keeps running and the images are loaded – except the animation starts only after the alert is closed.

    2) I tried to load the images to some invisible caching div, but of course I have to make it display:none, and again the same, the images are not loaded until the animation starts (and images are turned to display: block …

    this is the line, event and function name I use to load the images:

    itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback} 
    

    I know this might be insufficient input and code, but the script became very long so if a specific part could be usefull (or all of it?) just let me know… I don’t want to clutter the message 🙂

    Thanks for reading this,
    Yan

    • 1 1 Answer
    • 0 Views
    • 0 Followers
    • 0
    Share
    • Facebook
    • Report

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    1 Answer

    • Voted
    • Oldest
    • Recent
    • Random
    1. Editorial Team
      Editorial Team
      2026-05-26T07:52:47+00:00Added an answer on May 26, 2026 at 7:52 am

      I accomplished this by doing the following:

      • as I’m assembling the new carousel LI nodes, I add image element but I don’t set the src attribute
      • after I’m done adding the nodes to my carousel, I bind a method to the load event of the images. The load event increments a count of images that have loaded. Once the count is the same as the carousel size, then I know that all the images are loaded and I can start the animation.

      e.g.

      var imageLoadCount = 0;
      var jcarousel = $("#myCarousel").data("jcarousel");
      
      var imageLoaded = function() {
      
        imageLoadCount++;
      
        if(imageLoadCount === jcarousel.options.size) {
          // all the images have loaded.. begin the scroll
          jcarousel.options.auto = 5; // scroll every 5 seconds
          jcarousel.startAuto();
        }
      };
      
      var addItems = function(data) {
      
        jcarousel.size(data.length);
      
        $.each(data, function(index) {
          jcarousel.add(index + 1, getItemAsHtml(this));  // helper function to create node
        });
      
        $("img", carouselID).bind("load", imageLoaded);
      
        $("img", carouselID).each(function(index) {
          this.src = data[index].ImageUrl; // this triggers the image loaded event
        });
      };
      

      Note: this isn’t complete working code; it was edited to down for clarity. Also, keep in mind, the data I’m passing in to addItems() is array of json objects, each of which contains an ImageUrl property.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
    I'm working with an upstream system that sometimes sends me text destined for HTML/XML
    link Im having trouble converting the html entites into html characters, (&# 8217;) i
    That's pretty much it. I'm using Nokogiri to scrape a web page what has
    For some reason, after submitting a string like this Jack’s Spindle from a text
    Basically, what I'm trying to create is a page of div tags, each has
    I've got a string that has curly quotes in it. I'd like to replace
    I have a French site that I want to parse, but am running into
    I am currently running into a problem where an element is coming back from
    I have a text area in my form which accepts all possible characters from

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • SEARCH

    Footer

    © 2021 The Archive Base. All Rights Reserved
    With Love by The Archive Base

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.