-
Notifications
You must be signed in to change notification settings - Fork 5
Fix/pictique infinite scrolling mobile #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0c6f1b2
f757c6c
66fe564
4232138
951efe9
68cb261
b1f3beb
2d15433
d89c609
0c4eec8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,8 +29,6 @@ | |
| hasError = true; | ||
| img = '/images/user.png'; | ||
| } | ||
|
|
||
| $inspect(img); | ||
| </script> | ||
|
|
||
| {#if hasError || !img} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,9 @@ | |||||||||
| let isDrawerOpen = $state(false); | ||||||||||
| const sentinel = (node: HTMLElement) => { | ||||||||||
| // The sentinel is a direct child of the scrollable ul | ||||||||||
| const scrollContainer = node.parentElement; | ||||||||||
| const observer = new IntersectionObserver( | ||||||||||
| (entries) => { | ||||||||||
| for (const entry of entries) { | ||||||||||
|
|
@@ -40,12 +43,16 @@ | |||||||||
| const loadingMore = get(isLoadingMore); | ||||||||||
| if (hasMorePosts && !loading && !loadingMore) { | ||||||||||
| console.log('Triggering loadMoreFeed'); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the debug console.log. This console.log statement should be removed before merging. 🧹 Proposed fix if (hasMorePosts && !loading && !loadingMore) {
- console.log('Triggering loadMoreFeed');
loadMoreFeed();
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| loadMoreFeed(); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| }, | ||||||||||
| { rootMargin: '200px' } | ||||||||||
| { | ||||||||||
| root: scrollContainer as HTMLElement, | ||||||||||
| rootMargin: '200px' | ||||||||||
| } | ||||||||||
| ); | ||||||||||
| observer.observe(node); | ||||||||||
|
|
@@ -115,7 +122,7 @@ | |||||||||
| </script> | ||||||||||
|
|
||||||||||
| <MainPanel> | ||||||||||
| <ul class="hide-scrollbar h-screen overflow-auto md:h-dvh"> | ||||||||||
| <ul class="hide-scrollbar h-screen overflow-auto pb-24 md:h-dvh md:pb-0"> | ||||||||||
| {#if $isLoading && $posts.length === 0} | ||||||||||
| <li class="my-4 text-center">Loading posts...</li> | ||||||||||
| {:else if $error} | ||||||||||
|
|
@@ -222,7 +229,12 @@ | |||||||||
| </li> | ||||||||||
| {/each} | ||||||||||
| {#if $isLoadingMore} | ||||||||||
| <li class="my-4 text-center">Loading more posts...</li> | ||||||||||
| <li class="my-8 flex flex-col items-center justify-center py-8"> | ||||||||||
| <div | ||||||||||
| class="mb-3 h-8 w-8 animate-spin rounded-full border-2 border-t-transparent" | ||||||||||
| ></div> | ||||||||||
| <p class="text-base font-medium text-gray-700">Loading more posts...</p> | ||||||||||
| </li> | ||||||||||
| {/if} | ||||||||||
| {#if !$hasMore && $posts.length > 0 && !$isLoadingMore} | ||||||||||
| <li class="my-4 text-center text-gray-500">No more posts to load</li> | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: MetaState-Prototype-Project/prototype
Length of output: 1058
🏁 Script executed:
Repository: MetaState-Prototype-Project/prototype
Length of output: 470
🏁 Script executed:
Repository: MetaState-Prototype-Project/prototype
Length of output: 212
🏁 Script executed:
Repository: MetaState-Prototype-Project/prototype
Length of output: 111
🏁 Script executed:
Repository: MetaState-Prototype-Project/prototype
Length of output: 188
Scroll container detection is correct, but remove the debug log.
Using the sentinel's parent element as the IntersectionObserver root with a 200px rootMargin should fix mobile infinite scrolling. However, the console.log at line 46 needs to be removed per past feedback about unnecessary logging.
Remove the
console.log('Triggering loadMoreFeed');statement at line 46.Also verify that infinite scrolling works correctly on actual mobile devices (not just DevTools mobile view) and various browsers.
🤖 Prompt for AI Agents