Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @HostListener('window:scroll', ['$event']) checkScroll() {
- if (!this.getdata) {
- const componentPosition = this.el.nativeElement.offsetTop;
- const componentHeight = this.el.nativeElement.getBoundingClientRect().height;
- const scrollPosition = window.pageYOffset;
- const windowheight = window.outerHeight;
- const needposition = componentPosition + componentHeight - windowheight - 500;
- if (scrollPosition >= needposition) {
- this.getdata = true;
- this.getMoreNew();
- }
- }
- }
- getMoreNew() {
- if (!this.nomoredata) {
- const city = this.city;
- const find = this.find;
- const last = this.persones[this.persones.length - 1]['orderbyname'];
- this.httpClient.post<Array<any>>('/assets/api/index.php', {action: 'person', type: this.type, last, limit: this.limit, city, find })
- .subscribe(
- data => {
- if (data.length === 0) {
- this.nomoredata = true;
- this.getdata = false;
- } else {
- this.persones = this.persones.concat(data);
- this.getdata = false;
- }
- }
- );
- } else {
- this.getdata = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement