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 6570207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:43:38+00:00 2026-05-25T14:43:38+00:00

I am implementing virtual scrolling on a grid. The scrolling/on-demand loading feature is working

  • 0

I am implementing virtual scrolling on a grid. The scrolling/on-demand loading feature is working quite smoothly. However, when it’s detected that the user is scrolling quickly (defined as longer than 450ms) a semi-transparent div with a loading gif is displayed while the processing takes place.

My issue is that after the loading is done and the appending is finished, I make a call to hide the overlay expecting to see the updated grid. Instead, I have a 2-3 second delay then the overlay hides and the data shows.

The Question:

Part A: Why doesn’t the div still stay on screen even though the line of code to hide it comes after the appending … causing the unexpected 2-3 second wait with no progress/loading indicator to the user?

Part B: What can be done to ensure the overlay stays visible until the adding to the dom is complete and rendered?

the line of execution looks like this:

    CheckToFetch(id, $(gridScrollElm).scrollTop(), true);
    ToggleOverlay(gridScrollElm, false);

As you can see hear, the overlay ideally should hide after the data is loaded and rendered.

There is a chain of method calls going on behind CheckToFetch but I’ll just show the most relevant piece where appending occurs.

AppendData: function (id, data, firstTime)
{
    var gd = SGrid.GetGridData(id);
    var rowClass = (gd["RecordCount"] + 1) % 2; //sets us on correct course for adding AlternatingRow classes

    var grid = $('#' + id)
    var tbody = grid.children('tbody');

    var rowsToAdd = data["Records"];
    for (var r = 0; r < rowsToAdd.length; r++)
    {
        var elmsQueue = new Array(); //used to do efficient string concat, especially for IE
        elmsQueue.push('<tr>');
        for (var c = 0; c < gd['Columns'].length; c++)
        {
            elmsQueue.push('<td align="');
            elmsQueue.push(gd['Columns'][c]['DataAlign']);
            elmsQueue.push('" ');

            var id = rowsToAdd[r]["id"];
            var cell = rowsToAdd[r]["cell"];

            if (rowClass % 2 == 0)
            {
                elmsQueue.push('class="AlternatingRow">');
            }
            else
            {
                elmsQueue.push('>');
            }
            elmsQueue.push(cell[c]);
            elmsQueue.push('</td>');
        }
        elmsQueue.push('</tr>');
        tbody.append(elmsQueue.join(''));
        rowClass++;
    }
  • 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-25T14:43:38+00:00Added an answer on May 25, 2026 at 2:43 pm

    As to part A of your question, I can only assume, that repaint operation (process of actually showing result of javascript operations) can run independently from DOM operations and javascript execution. In your code, you append multiple elements to the DOM, the dom is updated, the reflow is issued to the browser, but that (reflow operation) doesn’t put javascript execution on hold. So if the reflow lasts a bit long, you end up in next javascript function being executed even though you don’t see the result of previous statement yet.

    There are couple of resources refering to paint events and dom operations performance: http://www.html5rocks.com/en/tutorials/speed/html5/ (check the Optimization Strategies part), and from one-and-only Paul Irish: http://paulirish.com/2011/viewing-chromes-paint-cycle/

    As to part B of your question. If my assumption from part A is right, the only thing you can do is make sure that repaint operations are limited to absolute minimum. In order to achive that, you should put on hold appending the elements until your full set is ready.
    In other words, keep collecting the new <tr> elements in an array (or a string), and only then do tbody.append(). To put it simple: move DOM manipulation out of loops.

    Defering actual DOM modifications It’s a common practice, and its recommended way of working with scripts that modify the DOM heavily.

    To get the every bit of performance, you could also try passing actual objects (created using document.createElement) to the append function, instead of strings, that (obviously) have to be parsed in order to get list of the elements you want to put in the DOM.

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

Sidebar

Related Questions

Windows-7 introduced a concept of virtual folder, called 'Libraries'. I am working on implementing
When implementing a pure virtual function in C++, is there a best-practices guideline that
I'm working on implementing an observer design pattern with a notification object that I
I want to create an application in PHP implementing virtual directory feature. Example: http://mydomain.com/user001
When overriding a class in C++ (with a virtual destructor) I am implementing the
I have a client that I'm wanting to move to a virtual private server.
When implementing polymorphic behavior in C++ one can either use a pure virtual method
I read about virtual constructors are used for implementing some design patterns, but didn't
I have an MVC3 application that I am implementing pjax into . Everything is
I've bought the virtual gallery from flashden but I'm having problems implementing it.. I'm

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.