getActiveY method
Implementation
double getActiveY(int round, int index) {
final numRounds =
branchRounds.length +
((finalMatch != null || thirdPlaceMatch != null) ? 1 : 0);
if ((finalMatch != null || thirdPlaceMatch != null) &&
round == numRounds - 1) {
if (branchRounds.isNotEmpty && branchRounds.last.length >= 2) {
final y1 = getActiveY(round - 1, 0);
final y2 = getActiveY(round - 1, 1);
final yCenter = (y1 + y2) / 2;
if (index == 0) {
return yCenter;
} else {
return yCenter + cardHeight + verticalGap;
}
} else {
final yFinal = getActiveY(round - 1, 0);
if (index == 0) {
return yFinal;
} else {
return yFinal + cardHeight + verticalGap;
}
}
}
if (round == 0) {
return topOffset + index * (cardHeight + verticalGap) + cardHeight / 2;
}
final parent1Y = getActiveY(round - 1, index * 2);
final parent2Y = getActiveY(round - 1, index * 2 + 1);
final expandedY = (parent1Y + parent2Y) / 2;
final compactY =
topOffset + index * (cardHeight + verticalGap) + cardHeight / 2;
final t = (pageOffset - (round - 1)).clamp(0.0, 1.0);
return ui.lerpDouble(expandedY, compactY, t)!;
}