Chat ux pagination with intersect

  • ssssadsadasd-1378372192550650020

    ssssadsadasd

    7 days ago

    [here](https://editor.nordcraft.com/projects/seno12/branches/start/components/test-scroll-up?canvas-height=800&canvas-width=800&selection=nodes.7xQPcxFd9K8K7aa2-mU_6&rightpanel=attributes), I am trying to build the logic of a chat with pagination. when I scroll up I want the new message to load, but without scrolling, i.e. my current view is not changed, but the messages are loaded at the top of the current message and I need to scroll up to view them.
    righ now, I cannot achieve this, and I immeidiately go to the top of the messages.
    anyone knows how to fix this? thanks
    here is a [video ](https://vimeo.com/1089332063/e7b2658137?ts=0&share=copy) that shows it
  • filip_dajkovic-1378645165299732531

    Filip Dajkovic

    6 days ago

    There you go, you should adjust the order of the data to work according to this structure but it should be the solution you're looking for. Let me know how it worked for you
  • ssssadsadasd-1378650797105090590

    ssssadsadasd

    6 days ago

    hey @Filip Dajkovic thanks for the help.
    however I am not sure it is exactly what I was aiming for. so my only problem was that whwn I scroll up to the intersect, the new items are loaded immediately and the scrollbar goes to the top. while I want the behavior to be similar to [this example](https://vimeo.com/1089452736/bb56af37ce?ts=0&share=copy), where the items are loaded but the scrollbar does not move up and it stays in the current item.

    not sure whether I failed to understand your example

    Thanks
  • filip_dajkovic-1378708093071917087

    Filip Dajkovic

    6 days ago

    If I'm not missing anything, my solution does that exactly, so when you scroll up and hit the observer, it adds new data and stays on the same place without scrolling or going up on its own.
  • filip_dajkovic-1378709013893615727

    Filip Dajkovic

    6 days ago

    I've shown the changes you should make, give it a shot and see if it works. You'll also need to adjust the structure of the data a bit for it to work properly, but I think that it will get you to a better data structure/order, as with my solution, you'll order items from latest to furthest (1, 2, 3...), not the other way around like you had. I think that will help with pagination too and make it much more understandable.
  • filip_dajkovic-1378726048845271181

    Filip Dajkovic

    6 days ago

    Getting close! Try setting top div's height to 100%
    1378726048576831498-CleanShot_2025-06-01_at_15.24.292x.png
  • ssssadsadasd-1378727728035139735

    ssssadsadasd

    6 days ago

    I set it to 100% but still the scroll goes to the top 😅
    I also set the root margin of the intersect to 128px 128px but it did not improve the behavior
  • filip_dajkovic-1378730314473537726

    Filip Dajkovic

    6 days ago

    Hmm, it works for me perfectly, take a look, am I missing something? I've also tested with Chrome & Firefox both.
  • ssssadsadasd-1378732308013781123

    ssssadsadasd

    6 days ago

    @Filip Dajkovic hmm I dont think it is working as I would want to. in second 19 you are at index 28. then intersect loads, and you immediately go to index 38. I simply want to remain at index 28.
  • filip_dajkovic-1378733571455586364

    Filip Dajkovic

    6 days ago

    I'm 99% sure it was just me scrolling fast, I've tested it again now and seems again like it's working properly, there's no auto-scrolling at all. I can't test it in browser but in editor everything works properly.
  • ssssadsadasd-1378734958402732032

    ssssadsadasd

    6 days ago

    @Filip Dajkovic indeed it's working. dont know why but I had not set the height = 100% or sth. sorry for the misunderstanding

    one last thing. I set the root-margin = 128px 128px and even tried 256px but it still loads only when I reach the absolute top. any idea how to make intersect trigger earlier? I can do this when I dont have this reverse feature, but here I cannot seem to find it
  • Tod-1378734960751415306

    Tod

    6 days ago

    Great job @ssssadsadasd! Your contribution to the Nordcraft Community just made you advance to Community Level 14! 🌲
  • filip_dajkovic-1378738386671501424

    Filip Dajkovic

    5 days ago

    I'm glad it's working! I don't have much experience with Intersection observer, somebody else could probably help better with that, but what I'd try is wrapping your list (ul) inside another div and placing intersection observer inside that div too, making it (observer) absolute and setting top (inset-top) position to be 128px or whatever value you want to
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1
    👍1