question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scrolled callback called on each scroll

See original GitHub issue

Hi,

The callback scrolled is called each time I used the mouse wheel, I try several configurations but none solved my issue.

This template is encapsulated in a body :

<div class="col-md-4 infinite-container" infinite-scroll [infiniteScrollThrottle]="1000" (scrolled)="onScrollDown()">
    <div class="content">
        <h1>{{ 'ADVERTISEMENT.SEARCH' | translate }}</h1>
    </div>
    <div class="content selectable" *ngFor="let result of results" (click)="onSelect(result)" [ngClass]="{'active' : isActive(result) }">
        <h4>{{ result.title }}</h4>
        <p>{{ result.price }} €</p>
    </div>
</div>
.infinite-container {
    height: 1000px;
}

Am I doing it wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
joaogarincommented, Mar 24, 2017

My issue was fixed by adding the missing DOCTYPE atrribute on the top of my html index file as mentioned here :

https://github.com/orizens/angular2-infinite-scroll/issues/7

😉

0reactions
iErikcommented, Jul 14, 2017

I was having the exact same problem. Solved it by changing the code from:

<div class="post-feed"
  infiniteScroll
  [infiniteScrollDistance]="2"
  [infiniteScrollThrottle]="500"
  (scrolled)="onScroll()"
>
  <ul class="post-feed-entries">
    <li class="post-feed-entry" *ngFor="let post of posts">
      <post-card
        [post]="post.data">
      </post-card>
    </li>
  </ul>
</div>

To:

<div class="post-feed" style="height: 100%"
  infiniteScroll
  [infiniteScrollDistance]="0"
  [infiniteScrollThrottle]="500"
  (scrolled)="onScroll()"
>
  <ul class="post-feed-entries">
    <li class="post-feed-entry" *ngFor="let post of posts">
      <post-card
        [post]="post.data">
      </post-card>
    </li>
  </ul>
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a callback for window.scrollTo? - Stack Overflow
I don't really know if a call back exists for scrollTo() but I think you can try setTimeout() only if you know the...
Read more >
Scroll Events and Intersection Observer - Beginner JavaScript
In this video we will learn about scroll events. A scroll event is when someone goes ahead and scrolls on the page or...
Read more >
Quick Tip: How to Throttle Scroll Events - SitePoint
The browser will execute the callback every single time the user scrolls, which can be many events per second. If the callback performs...
Read more >
Document: scroll event - Web APIs - MDN Web Docs - Mozilla
The scroll event fires when the document view has been scrolled. To detect when scrolling has completed, see the Document: scrollend event.
Read more >
Decouple the scroll event from the callback functions using ...
r/javascript - scrolling.js: Decouple the scroll event from the callback ... a bad idea considering every device and browser calls the event differently...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found