[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:
parent
7f8ddb514d
commit
9531e64c0d
|
@ -2057,11 +2057,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||
updateScroll = () => {
|
||||
const maxColumns = 9;
|
||||
const maxRows = 9;
|
||||
const onScreenFirstIndex = this.scrollCursor * 9;
|
||||
const onScreenLastIndex = Math.min(this.filteredStarterContainers.length - 1, onScreenFirstIndex + 81);
|
||||
|
||||
this.starterSelectScrollBar.setPage(this.scrollCursor);
|
||||
|
||||
let pokerusCursorIndex = 0;
|
||||
this.filteredStarterContainers.forEach((container, i) => {
|
||||
if (i < onScreenFirstIndex || i > onScreenLastIndex) {
|
||||
container.setVisible(false);
|
||||
return;
|
||||
} else {
|
||||
const pos = calcStarterPosition(i, this.scrollCursor);
|
||||
container.setPosition(pos.x, pos.y);
|
||||
|
||||
|
@ -2128,6 +2134,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||
container.candyUpgradeIcon.setVisible(false);
|
||||
container.candyUpgradeOverlayIcon.setVisible(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue