aurelia / ui-virtualization

A plugin that provides a virtualized repeater and other virtualization services.
MIT License
90 stars 45 forks source link

Table shows no rows if you scroll too fast #172

Open catsalive opened 4 years ago

catsalive commented 4 years ago

I'm submitting a bug report

Please tell us about your environment:

Current behavior: This no longer works again (if you scroll slightly too fast the rows disappear, the height of the bottom placeholder tr tag appears to be too high):

<table style="width:500px; height: 200px; overflow-y:scroll; display:block">
  <tr virtual-repeat.for="user of users" style="width:500px; height: 50px">
    <td>
      ${user.avatar_url}
    </td>
  </tr>
</table>

Expected/desired behavior:

bigopon commented 4 years ago

@catsalive the issue you face is probably because the difference in amount of work browser has to do. For table/tr, its relatively higher than div, and thus could make some of our callback in the plugin fire too early, thus having wrong calculation. This will be even more difficult on Firefox as they may have flakier timing implementation. I would suggest doing a manual event dispatch on one element to re-trigger the calculation. You can find the example in the readme.

Please note that you will have to scroll very very fast, continously for this to happen (im guessing)

catsalive commented 4 years ago

@bigopon Thank you for responding so quickly. It is true, that very similar code, but with divs has no issues like this. I did not have to scroll very fast at all to get the issue to come up and I only have 242 rows. Can you point out the manual event dispatch you're referring to in the readme? Is that the infinite-scroll-next attribute?

bigopon commented 4 years ago

@catsalive Sorry I forgot about this. What you can do is to dispatch one of the following 2 events:

export declare const VirtualizationEvents: {
    scrollerSizeChange: "virtual-repeat-scroller-size-changed";
    itemSizeChange: "virtual-repeat-item-size-changed";
};

on the scrolling element. if it's a <div/> containing a table, then you would do:

myDiv.dispatchEvent(new CustomEvent(VirtualizationEvents.scrollerSizeChange));
sheetalvarshney38 commented 3 years ago

@bigopon I am still facing this issue, quick scroll works fine on chrome but not on other browsers. I tried manual event dispatch as you suggested but it won't work either. Can you help!!

bigopon commented 3 years ago

it's unlikely that this is actionable. Even for native scrolling, browsers struggle to keep up if you scroll too fast. You can try to open a long long page, and then scroll really fast up and down, browser can't keep up with that basic functionality sometimes.