Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throttling logic in onScroll seems to be backwards/incorrect (i.e. it always updates) #466

Open
zzorba opened this issue Dec 2, 2021 · 0 comments

Comments

@zzorba
Copy link

zzorba commented Dec 2, 2021

While investigating some slow updates (repeatedly seeing old content as I scrolled -- more visible on Android but also happening pretty regularly on iOS) I noticed this line of code which appears to be doing nothing?

const now = new Date().getTime();
if (this._lastTick - now > 30) {
this._lastTick = now;
return;
}
this._lastTick = now;

this._lastTick will always be less than now, so the early return will never be executed AFAICT. Diagnosing it with some console.logs showed this to be the case as well (the early return never executed).

I think this logic should be inverted as follows:

    const now = new Date().getTime();
    if (now - this._lastTick < 30) {
      return;
    }
    this._lastTick = now;
    this._shouldUpdateContent &&
      this._groupRefs.forEach((group) =>
        idx(() => group.current.contentConversion(offsetY))
      );

And possibly it should be using the updateTimeInterval prop which currently seems to be documented, but completely unused in the code (unless I missed something).

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

No branches or pull requests

1 participant