Skip to content

Optimise scrolling to make scroll-handle scrolling feel better #11752

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

Merged
merged 7 commits into from
May 10, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions browser/src/app/TilesMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ class TileManager {
// The tile expansion ratio that the visible tile area will be expanded towards when
// updating during scrolling
private static directionalTileExpansion: number = 2;
private static pausedForDehydration: boolean = false;

//private static _debugTime: any = {}; Reserved for future.

Expand Down Expand Up @@ -475,6 +476,26 @@ class TileManager {
}
}

if (this.pausedForDehydration) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my previous comment was intended for this =)

// Check if all current tiles are accounted for and resume drawing if so.
let shouldUnpause = true;
for (const key in this.tiles) {
const tile = this.tiles[key];
if (
tile.distanceFromView === 0 &&
!tile.needsFetch() &&
tile.hasPendingUpdate()
) {
shouldUnpause = false;
break;
}
}
if (shouldUnpause) {
app.sectionContainer.resumeDrawing();
this.pausedForDehydration = false;
}
}

this.garbageCollect();
}

Expand Down Expand Up @@ -1489,12 +1510,11 @@ class TileManager {
}

// If we dehydrated a visible tile, wait for it to be ready before drawing
if (dehydratedVisible) {
if (dehydratedVisible && !this.pausedForDehydration) {
app.sectionContainer.pauseDrawing();
this.endTransaction(() => {
app.sectionContainer.resumeDrawing();
});
} else this.endTransaction(null);
this.pausedForDehydration = true;
}
this.endTransaction(null);

return queue;
}
Expand Down