Skip to content
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

fix: infinite scroll doesn't work when bound to window #74

Open
lettucebowler opened this issue Mar 29, 2023 · 1 comment
Open

fix: infinite scroll doesn't work when bound to window #74

lettucebowler opened this issue Mar 29, 2023 · 1 comment

Comments

@lettucebowler
Copy link

lettucebowler commented Mar 29, 2023

window.scrollHeight is undefined, so it never triggers the update when this action is used on svelte:window. I'm currently working around this using the following patch file with pnpm patch:

index 5a175f44fab9cffb31af5355f2fd4d3200ce2c3b..3e9f6b14b3ffd1fe05d36de386d2eaa8fbfd3caa 100644
--- a/package/actions/infiniteScrollAction/index.js
+++ b/package/actions/infiniteScrollAction/index.js
@@ -78,7 +78,11 @@ function check({ disabled, scrollEventTarget, element, distance, cb, }, force) {
     let viewportBottom = viewportScrollTop + getVisibleHeight(scrollEventTarget);
     let shouldTrigger = false;
     if (scrollEventTarget === element) {
-        shouldTrigger = scrollEventTarget.scrollHeight - viewportBottom <= distance;
+        if (scrollEventTarget === window) {
+            shouldTrigger = document.documentElement.scrollHeight - viewportBottom <= distance;
+        } else {
+            shouldTrigger = scrollEventTarget.scrollHeight - viewportBottom <= distance;
+        }
     }
     else {
         let elementBottom = getElementTop(element) -
@ankurrsinghal
Copy link
Owner

Hi, @lettucebowler I will get back to you on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants