dhilt / vscroll-native

Virtual scroll module for native javascript applications
https://dhilt.github.io/vscroll-native/
MIT License
10 stars 2 forks source link

Feature: Flex Grid VScroll #1

Open john-theo opened 3 years ago

john-theo commented 3 years ago

Amazing work! I have been looking for a js vscroll solution, without any frameworks. And I ended up here. I tried the demo, and am largely satisfied with the current result. But when it comes to "multi-column" vscroll, most vscroll project just put it in the wip or gotcha section. But I think in my case, padding height of a flex css grid is calculatable.

I have a bunch of square containers with their parent has these css styles:

display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: flex-start;
gap: 20px;

How should I use this project? Do you have any suggestions for me?

dhilt commented 3 years ago

@John-Theo I'm very glad that you have found this project. Of course, multi-column issue has been raised several times in related ngx-ui-scroll project, and this is what we have reached at this moment:

Both cases provide an additional "grouping" layer between the initial flat dataset and the Scroller, which also wants flat list. Scroller's item becomes a group of initial items. The logic of this layer can be taken from app.component.ts. Templating should be tweaked. You'll need to move inner grouping template (*ngFor) from the html page code to the item template factory, like

  const template = (group: Item[]) =>
    `<div class="group">` +
      group.map(item =>
        `<div class="item"><span>${item.data.id}</span>) ${item.data.text}</div>`
      ) +
    `</div>`

If you can start make vscroll-native grouping demo (for example by forking the first stackblitz sample), I will help you to finish it and make it work.

john-theo commented 3 years ago

Thank you so much! I am working on a project that needs virtual scroll functionality, I will try to figure something out based on your example. Any luck on it, I would create a CodePen or something and keep you posted here! Thanks again for your suggestion!

dhilt commented 3 years ago

@John-Theo I dream to create a list of vscroll-native demos on stackblitz, codepen or whatever, and a grouping demo would be very important. I can't find time to do this by myself right now, but I gladly would join if you take any steps in this direction.