-
Notifications
You must be signed in to change notification settings - Fork 366
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
"loaded" doesn't stop loading #55
Comments
Simplified the onInfinite, but same result:
|
I have changed the distance calculation method since |
When I use in nested component, I have same issue. |
I'm sorry it was my misunderstanding. I used vue within Laravel, so it may be caused by laravel blade tempalte in my case :) |
I currently experiencing this kind of issue, it creates multiple request during page loading I'm using Laravel 5.4 and axois. Below is my JS code
|
I am also experiencing this issue. The event keeps on firing even if I am not scrolling. Its weird because I just followed the guide. I am using elementUI's table |
@PenAndPapers @rodwin which version of |
I'm using "vue": "^2.0.1" and "axios": "^0.15.2". |
I thought it was not compatible with axios so I tried to use "vue-resource": "^1.2.1", but still no luck |
@PenAndPapers I think it was not caused by |
I'm seeing this issue as well with VueJS 2.3.4. I'm also seeing it send out two events each time. |
@PeachScript I've tried Vue.js v2.2.6 still not working, im not using vue router on my project |
@mcmillion @PenAndPapers I need your help to find the real reason, could you reproduce this problem on JSFiddle? You can use |
I have same issue (Vue 2.3) and vue-infinite-loading (2.1.3) sends event all time. Similar case to @DaveSanders. @PeachScript Could the issue be related to css? |
To make matters worse (at least for finding the bug) its stopped doing it for me, and seems to be working fine now. I'm really not sure what I've changed. I'm guessing its related to page structure, and I did move some things around when we redesigned the screen. I was going to go back to look at old commits to see if I can find the difference, but I've been slammed with crunch time here. |
@DaveSanders |
@DaveSanders Ive run into the same problem when I nest 'infinite-loading' in divs while using window as the scroll parent. What I've noticed in the infiniteLoading.vue file is that the getCurrentDistance function does not account for the infinite-loading component to be further down the page then it is. When i change the function to the following everything is resolved. function getCurrentDistance(elm, dir) {
let distance;
const scrollTop = isNaN(elm.scrollTop) ? elm.pageYOffset : elm.scrollTop;
if (dir === 'top') {
distance = scrollTop;
} else {
let scrollElmHeight;
if (elm === window) {
scrollElmHeight = window.innerHeight;
distance = this.$el.getBoundingClientRect().top - scrollTop - scrollElmHeight - (elm.offsetTop || 0);
} else {
scrollElmHeight = elm.getBoundingClientRect().height;
distance = this.$el.offsetTop - scrollTop - scrollElmHeight - (elm.offsetTop || 0);
}
}
return distance;
} |
@vbabenko I'm not sure how this issue is caused, maybe related to CSS/HTML. The tricky place is, we have no way to reproduce it, so it is difficult to find the real reason... |
@DaveSanders waiting for your good news, thank you very much! |
@vbabenko is there has some specials in your problem project? Such as the different scroll container, the different front-end router, the different nested HTML structure, etc. |
I'm having this issue again today too. In my case I think its because the component that have infiniteLoading init and running is hidden and it keeps loading till I open it.
The tab-bkgrnd component is hidden by default and that is where I have infiniteLoading setup and running. When I first access the page infiniteLoading keeps loading forever until I click on tab-bkgrnd. If I change tab-bkgrnd to open by default then its only load once and working as expected when scrolling down. |
@duyhung85 yep, because the |
@PeachScript I think the issue appear when styles wrote in bad manner, like this
in this case it will invoke function to the end while data exists. (open console to see invocation) when you comment Maybe it can help. When I have time I will try debug source file to be sure on 100% |
@vbabenko it's a very useful information, thank you very much! |
@DaveSanders @PenAndPapers @rodwin @vbabenko @adamyarger @mcmillion hi everyone, sorry to bother, could you tell me does your scroll container has a fixed height? |
@PeachScript, it's okay, thank you for your library, it's awesome. In my case - no (everything positioning by flexbox), my scroll container has |
@PeachScript, no im using the window to scroll. I believe i may have been using an older version of the component before when when offsetTop was being used to measure the distance, it now looks like getBoundingClientRect().top is being used. So everything works as expected now. |
@vbabenko thanks for your appreciation! This plugin will calculate distance through the So I think should to add a additional condition to process it, I will as soon as possible. |
@adamyarger got it, thanks for your feedback! Best regards. |
@vbabenko @Akari1987 I have encountered a thorny problem. For now, this plugin will find the closest parent node that has |
@Akari1987 thanks, waiting for your good news! |
Hi all participants @DaveSanders @Akari1987 @PenAndPapers @rodwin @mcmillion @vbabenko @adamyarger @duyhung85 , I have no idea about how to find the real scroll parent, but this issue has been created for 2 months, so I plan to add a special property to solve it, looks like this: <div infinite-wrapper>
<div style="overflow: auto;">
<infinite-loading force-use-infinite-wrapper="true"></infinite-loading>
</div>
</div> The special property called What do you think about the solution? And how about the attribute name Best regards. |
Sounds good. It would be nice to update documentation, this property is not obvious for those who doesn't aware about this issue |
@vbabenko perhaps we can observe the number of times when this component be trigger, and we can throw a warning if it was triggered many times in a short time, do you think it is feasible? |
I dunno but I have been testing around, what i have noticed is that first you have to set the height of your body to window.onscroll = function(ev) {
if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
// scroll hits the floor, then you can call the function
}
}; |
@JefferyHus Sorry, I don't know what do you want to solve...Is your solution related to this issue? |
yes it is, when ever I scroll down once the loading never stops and keeps calling my function to the infinite, so I had to change the function on the scroll listener and it worked now. |
@JefferyHus thanks for your reply! Perhaps there are many reasons for this issue, I need your help, could you reproduce your problem on JSFiddle? |
@PeachScript emmm, I will try even tho im not sure if it will reproduce again but will also put the solution I did, once im free |
Hi everyone, v2.2.0 has been released, include the |
@PeachScript thanks a lot for |
@junpls this component will only search scroll wrapper when it is initialized, what is the situation that you need to change scroll wrapper during runtime? |
@PeachScript this is what I'm trying: |
@junpls I see, thanks for your explanation, I will add responsive support the |
This works for me:
Ref: https://scotch.io/tutorials/simple-asynchronous-infinite-scroll-with-vue-watchers |
please add
infinite-wrapper |
I also experiencing this issue, but not about CSS/html ,it was coursed by the array increase method, when i increase array like this |
There will be one more case that causes calling handler multiple time. Here is my handler. I've added a filter statement to make sure there are no duplicated records. infiniteHandler($state) {
axios.get(api, {
params: {
page: this.page,
},
}).then(({ data }) => {
if (data.hits.length) {
this.page += 1;
const newHits = data.hits.filter((hit) =>
this.list.every((item) => item.id !== hit.id)
);
this.list.push(...newHits);
$state.loaded();
} else {
$state.complete();
}
});
} The problem comes when the |
v2.1.3 - for some reason the "loaded" emit isn't stopping it from continuing to load results down the page. I'm pretty sure this was working before, but I can't figure out why this is happening.
So, basically even though I haven't scrolled down, it keeps hitting my server and loading more results. Here's my onInfinite function:
My template:
I did put console logs in and it IS hitting that else where it sends the loaded emit. I also changed it to :complete and it stopped calling at that point in the code. So it is emitting, it just seems like its not caring - or for some reason it thinks that its scrolled down.
Anything I'm doing wrong? Or any ideas on how to debug it further?
The text was updated successfully, but these errors were encountered: