Avoid div-by-0 in case Flex item sizes are all 0. Resolves #332, resolves #334

This commit is contained in:
Oliver 2019-10-17 11:33:25 +02:00
parent f8bc69b903
commit de7ae86b5b
1 changed files with 7 additions and 3 deletions

10
flex.go
View File

@ -149,9 +149,13 @@ func (f *Flex) Draw(screen tcell.Screen) {
for _, item := range f.items {
size := item.FixedSize
if size <= 0 {
size = distSize * item.Proportion / proportionSum
distSize -= size
proportionSum -= item.Proportion
if proportionSum > 0 {
size = distSize * item.Proportion / proportionSum
distSize -= size
proportionSum -= item.Proportion
} else {
size = 0
}
}
if item.Item != nil {
if f.direction == FlexColumn {