Comments (5)
Based on your example this should work:
export class App implements OnInit{
_contactsTotal:any; // get 500 data from server
_contactsToRepeatInView:any;
_waitData: boolean; //no ajax call if we are already waiting one
constructor(private _contactService: ContactService) {}
ngOnInit():any {
this._contactsToRepeatInView = []
this._waitData = false;
this._contactService.getImages().map(res => res.json()).subscribe(data => {
this._contactsTotal = data;
this._contactsToRepeatInView = this._contactsTotal.splice(0,100); // show only 100 data from server response
});
}
onScrollDown () {
this._contactsToRepeatInView = this._contactsToRepeatInView.concat(this._contactsTotal.splice(0,100)) // when scrollDown concat() 100 additional data to actual view, from this._contactsTotal
if(this._contactsTotal.length === 0){ //when this._contactsTotal equal 0 we do another ajax call and so the same stuff
if(this._waitData === false){
this._waitData = true;
this._contactService.getImages().map(res => res.json()).subscribe(data => {
this._contactsTotal = data
this._contactsToRepeatInView = this._contactsToRepeatInView.concat(this._contactsTotal.splice(0,100))
this._waitData = false;
});
}
}
}
}
from ngx-infinite-scroll.
That's because you always set _waitData
to true
before checking it.
from ngx-infinite-scroll.
hi @istiti
the purpose of this directive is to invoke the handler every time it scrolls after the specified "distance".
other specific logics should be resolved inside the component that's using it.
from ngx-infinite-scroll.
Could you please check my code I tried to implement something into component, with this._waitData properties but event with this solution I have more than one http call, I do not understand
from ngx-infinite-scroll.
do you have better implementation ? even pseudo-code :) what is the best way to implement this in onScrollDown() method
from ngx-infinite-scroll.
Related Issues (20)
- Support Angular@15
- Are you still maintaining this library? HOT 2
- Can ngx-infinite-scroll work with mat-select / mat-option HOT 1
- Shipping without @scarf/scarf HOT 1
- Angular v16 support HOT 3
- Facing issue in ngx-infinite-scroll version 16.0.0 HOT 2
- error NG6002: 'InfiniteScrollModule' does not appear to be an NgModule class. HOT 5
- Scroll events not fired when using Chrome devtools device mode
- Adding new standalone APIs HOT 1
- Scroll events not fired with angular 16 HOT 2
- Repeated events onScrollDown HOT 1
- Trigger event of no scrollbar is present HOT 2
- Upgrade to Angular 17 ? HOT 8
- After reloading the data, the scrolling event becomes invalid HOT 1
- List jumping when new items are loaded HOT 1
- Infinite scroll doesnt reset to top on route change
- console warning "violation 'settimeout' handler took n ms" coming multiple times
- Angular 18 support for ngx-infinite-scroll HOT 2
- InfiniteScrollModule is deprecated ? angular 18, ngx-infinite-scroll 18 HOT 1
- Add ability to set at least px to infiniteScrollDistance
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-infinite-scroll.