symfony / ux

Symfony UX initiative: a JavaScript ecosystem for Symfony
https://ux.symfony.com/
MIT License
853 stars 315 forks source link

[Site] Infinite Scroll - Remove wrapper #1748

Closed seb-jean closed 7 months ago

seb-jean commented 7 months ago

Hi, I would like to know if there is a possibility to avoid having the element having the ProductGrid_page wrapper class for each page on demo https://ux.symfony.com/demos/live-component/infinite-scroll?

Currently it is like this: Capture

The idea would be to have this:

Capture1

Would it be possible to have the <articles> directly?

Thanks :)

smnandre commented 7 months ago

It can be done, but only with some DOM manipulation.

That was my first attempt earlier this year...

Let's say you're rendreding "page 2"

<div # results>
</div>
<div #page1></div>
<div #page2 class="current">
    {% for ... in results %} .... {% endfor } %}
</div>

In JS just before the render you can select all items from the current page (so, just before page2 it's still page1 in the DOm) and move them to the #result div.

But i wanted something that would require no "manipulation" for maximal browser performance / no CLS.

All this obviously only based on what i tried... there are probably a lot of other solutions (and i'd be really interested to ear about them and update the demo :) )

seb-jean commented 7 months ago

There is this video made with Laravel Livewire: https://www.youtube.com/watch?app=desktop&v=B6TtWdA7uS0

There is also this article: https://apexcode.dev/blog/infinite-scroll-with-laravel-and-livewire, with a demo: https://play.apexcode.dev/blog

If that helps :)

smnandre commented 7 months ago

Do you want to try a PR ?

seb-jean commented 7 months ago

I have no idea how I could improve this.

smnandre commented 7 months ago

I found something! I'll use/show it for the part 2/2 :)

seb-jean commented 7 months ago

Super-Simon 🦸‍♂️ !

smnandre commented 5 months ago

Thanks @seb-jean, this one is for you ;) https://github.com/symfony/ux/pull/1887

seb-jean commented 5 months ago

Thanks @smnandre, this emoji is for you: :ok_hand: