[Enhancement] Optimize updateScroll function in starter select UI (#3268)

* optimize updateScroll function to update only the container within the screen

* fix eslint
This commit is contained in:
Leo Kim 2024-08-01 01:00:46 +09:00 committed by GitHub
parent 7f8ddb514d
commit 9531e64c0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 65 additions and 58 deletions

View File

@ -2057,11 +2057,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
updateScroll = () => { updateScroll = () => {
const maxColumns = 9; const maxColumns = 9;
const maxRows = 9; const maxRows = 9;
const onScreenFirstIndex = this.scrollCursor * 9;
const onScreenLastIndex = Math.min(this.filteredStarterContainers.length - 1, onScreenFirstIndex + 81);
this.starterSelectScrollBar.setPage(this.scrollCursor); this.starterSelectScrollBar.setPage(this.scrollCursor);
let pokerusCursorIndex = 0; let pokerusCursorIndex = 0;
this.filteredStarterContainers.forEach((container, i) => { this.filteredStarterContainers.forEach((container, i) => {
if (i < onScreenFirstIndex || i > onScreenLastIndex) {
container.setVisible(false);
return;
} else {
const pos = calcStarterPosition(i, this.scrollCursor); const pos = calcStarterPosition(i, this.scrollCursor);
container.setPosition(pos.x, pos.y); container.setPosition(pos.x, pos.y);
@ -2128,6 +2134,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
container.candyUpgradeIcon.setVisible(false); container.candyUpgradeIcon.setVisible(false);
container.candyUpgradeOverlayIcon.setVisible(false); container.candyUpgradeOverlayIcon.setVisible(false);
} }
}
}); });
}; };