InfiniteScroll bug or problem

Im getting errors in any page im using InfiniteScroll

This is the error that ionic is giving me

Uncaught TypeError: Cannot read property 'timeStamp' of null
    at InfiniteScroll._onScroll (main.js:61600)
    at SafeSubscriber.schedulerFn [as _next] (main.js:4216)
    at SafeSubscriber.__tryOrUnsub (main.js:43527)
    at SafeSubscriber.next (main.js:43474)
    at Subscriber._next (main.js:43414)
    at Subscriber.next (main.js:43378)
    at EventEmitterProxy.Subject.next (main.js:47145)
    at EventEmitterProxy.EventEmitter.emit (main.js:4190)
    at ScrollView.scroll.onScroll (main.js:38559)
    at ScrollView.setScrolling (main.js:95286)

Current Ionic Info

global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts : 1.3.7
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.4.2

System:

    Node       : v6.10.2
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 3.10.10

What is the code you are trying to use?

@agrupalo
that the bug actually when you add scrolltotop() in infinite scroll.I am also facing the same issue

Here is a Github issue about this:


Add your +1

There might also be a solution.

thanks @Sujan12 for your help. But its very hard to find a solution . Is there any alternative for scrollToTop().Cant spend much time on this has been sitting over it for more than 3 days. If someone could then it will be a great!!!

There are multiple PRs at https://github.com/ionic-team/ionic/pulls for InfiniteScroll - maybe one fixes this.

The error is due to:

 if (this._lastCheck + 32 > ev.timeStamp) {
            // no need to check less than every XXms
            return 2;
        }
        this._lastCheck = ev.timeStamp;

You can fix it by changing this part of the code in your node_modules, but ofcourse that is not a good solution.

I fixed it via a setTimeout():

  scrollToTopEnabled: boolean = true;

  scrollToTop() {
    if(this.scrollToTopEnabled) {
      this.scrollToTopEnabled = false;
      this.content.scrollToTop()

      setTimeout(() => {
        this.scrollToTopEnabled = true;
      }, 500)
    }
  }

This way the function can never be called within 32 milliseconds and the error will not be fired again

i had this issue when i used a manual scrolling in my .ts page.that is “content.scrolltop”…something like that. my best guess is that that too condradicts and cause the same issue.finally i used css for the same scrolling effecttry this link…it helps.

Have you tried using Angular CDK? Mike with Ionic tweeted about it. I believe they are recommending its use.