Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

bug(infinite-scroll): throws uncatchable error if scrollToTop is called before it is resolved #34

Open
ionitron-bot bot opened this issue Nov 1, 2018 · 1 comment
Labels

Comments

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 1, 2018

Ionic version: (check one with "x")
[ ] 1.x (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[x] 3.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
Having infinite scroll, calling content.scrollToTop() before last content.scrollToTop() resolves, throws an un-catchable error, and breaks the app.

ERROR TypeError: Cannot read property 'timeStamp' of null
at InfiniteScroll._onScroll (infinite-scroll.ts:233)
at SafeSubscriber.schedulerFn [as _next] (event_emitter.ts:121)
at SafeSubscriber.__tryOrUnsub (Subscriber.ts:254)
at SafeSubscriber.next (Subscriber.ts:204)
at Subscriber._next (Subscriber.ts:135)
at Subscriber.next (Subscriber.ts:95)
at EventEmitterProxy.Subject.next (Subject.ts:61)
at EventEmitterProxy.EventEmitter.emit (event_emitter.ts:80)
at ScrollView.scroll.onScroll (content.ts:437)
at ScrollView.setScrolling (scroll-view.ts:74)

Expected behavior:
Either be able to catch the error, or better yet don't error.

Steps to reproduce:
Plunker: http://plnkr.co/edit/ptdHfTMhBxwvAOOUvizQ?p=preview
Steps:

  • Scroll to 500 or so
  • Tap scrollToTop twice fast
  • Look at console. If no error, try again.

You can do it only once though (per refresh), because it kills the thread.

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

global packages:

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

local packages:

    @ionic/app-scripts              : 2.0.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Ionic Framework                 : ionic-angular 3.5.0

System:

    Node       : v8.1.2
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 5.0.3 
@Zizazorro
Copy link

You can fix this temporarily via:

  scrollToTopEnabled: boolean = true;

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

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant