showing results for - "based on scroll position and get data attribute javascript"
Stefania
25 Jul 2016
1<div class="imageWrap"(scroll) = "onScroll($event,imageEl)">
2  <ul>
3  <li #imageEl * ngFor="let data of images; let i = index"
4  [attr.data-image-id] = "image.id" >
5    <div><img src ="{{data.img}}" width = "500" height = "600" /> </div>
6  </li>
7  </ul>
8  </div>
9
10@HostListener('scroll', ['$event'])
11onScroll(event: any, indexI ?) {
12  let els = document.getElementsByTagName("li");
13  let offsetHeight = event.target['offsetHeight'];
14  let scrollTop = event.target['scrollTop'];
15  let scrollHeight = event.target['scrollHeight'];
16  this.getImageById(id);
17}
18getImageById(id){
19  this.apiService.getimageData(id).subscribe(images => this.images = images);
20}
21