Skip to content

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

@zzorba

Description

@zzorba

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions