Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. @HostListener('window:scroll', ['$event']) checkScroll() {
  2. if (!this.getdata) {
  3. const componentPosition = this.el.nativeElement.offsetTop;
  4. const componentHeight = this.el.nativeElement.getBoundingClientRect().height;
  5. const scrollPosition = window.pageYOffset;
  6. const windowheight = window.outerHeight;
  7. const needposition = componentPosition + componentHeight - windowheight - 500;
  8.  
  9. if (scrollPosition >= needposition) {
  10. this.getdata = true;
  11. this.getMoreNew();
  12. }
  13. }
  14.  
  15. }
  16.  
  17. getMoreNew() {
  18. if (!this.nomoredata) {
  19. const city = this.city;
  20. const find = this.find;
  21. const last = this.persones[this.persones.length - 1]['orderbyname'];
  22. this.httpClient.post<Array<any>>('/assets/api/index.php', {action: 'person', type: this.type, last, limit: this.limit, city, find })
  23. .subscribe(
  24. data => {
  25. if (data.length === 0) {
  26. this.nomoredata = true;
  27. this.getdata = false;
  28. } else {
  29. this.persones = this.persones.concat(data);
  30. this.getdata = false;
  31. }
  32. }
  33. );
  34. } else {
  35. this.getdata = false;
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement