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.

How to implement infinite scroll with RouteReuseStrategy. Always emit scrolled events.

See original GitHub issue

In our application we are using RouteReuseStrategy to reapply elements.

Intinite scroll is used with the following settings: infiniteScroll [infiniteScrollDistance]="0" [infiniteScrollThrottle]="250" When component is detached, window scroll event handler is still persist for infiniteScroll, causing it to emitting (scrolled) event every scroll.

Why is it emitting scrolled events when its not in a viewport?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
konstantinosftwcommented, Jan 9, 2021

Hey @Omi0, I managed to make your solution work!

Tips for anyone stuck:

  1. Once you add all of Omi0’s code to your project, you need to replace your app’s <router-outlet> with the new <app-router-outlet> that you just created from the article.
  2. If you want to stop listeners that run on child components, you’ll need to call changeDetectorRef.detectChanges() after any change you make in your parent’s onDetach() function, like so:
onDetach() { 
  this.isDetached = true;   // or any other variable you are passing to the child
  this.changeDetectorRef.detectChanges();   // to detect the above change and actually send the variable to the child
}
1reaction
Omi0commented, Sep 30, 2020

@konstantinosftw I have even written an article about it. Scroll to 3 method. Hope it answers your question.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Implement Infinite Scrolling with React.js | Pluralsight
Here in this guide, we will develop a simple custom infinite scrolling mechanism that helps us to load data based on a scroll...
Read more >
Saving scroll position with RouteReuseStrategy - Medium
So, we have to implement saving the scrolls by ourselves. There may be a lot of ways here: custom directive;; component-wide provider;; custom ......
Read more >
ngx-infinite-scroll event not being triggered when scroll is ...
I am trying to implement infinite scroll using ngx-infinite-scroll in an angular 4 app but it its not being triggered.
Read more >
Infinite Scroll with Vue - YouTube
Want more? Explore the library at https://codecourse.comOfficial sitehttps://www.codecourse.comTwitterhttps://twitter.com/teamcodecourse.
Read more >
Infinite Scroll with Vue.js and Intersection Observer - Netguru
Our Trigger component creates an Intersection Observer and emit an event when the component enters the viewport. What we need to do now...
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