Closed mxgrn closed 1 month ago
Hi dear @mxgrn, I just saw this out of curiosity and of course you'll have to wait for the LiveView team to see if it could be a bug or not.
So as you see this link
https://hexdocs.pm/phoenix_live_view/bindings.html#scroll-events-and-infinite-stream-pagination
You should define what time your scroll is finished not to scroll to last record
<ul
id="posts"
phx-update="stream"
phx-viewport-top={@page > 1 && "prev-page"}
phx-viewport-bottom={!@end_of_timeline? && "next-page"}
phx-page-loading
class={[
if(@end_of_timeline?, do: "pb-10", else: "pb-[calc(200vh)]"),
if(@page == 1, do: "pt-10", else: "pt-[calc(200vh)]")
]}
>
....
<div :if={@end_of_timeline?} class="mt-5 text-[50px] text-center">
🎉 You made it to the beginning of time 🎉
</div>
If you do not use it as a InfiniteScroll, so I think it is better to use
phx-hook
Thanks for the intel @shahryarjb! I agree the current behavior is working as intended. Thanks!
Environment
Actual behavior
When
handle_event
forphx-viewport-bottom
takes longer than a couple hundred milliseconds, I'm seeing a scrolling glitch caused (probably) by LiveView callinglastChild.scrollIntoView
. The glitch prevents seeing the content that is below the infinite scroll HTML and causes scroll jerking.Here's the code that's needed to reproduce the issue in a vanilla Phoenix app (let me know if you want a complete app on GitHub).
Expected behavior
In my example, the content of the
h2
tag should be visible whilehandle_event
executes, and no scroll glitching should take place.