exyte/ScalingHeaderScrollView

Returning `nan`

petomuro opened this issue · 1 comments

https://github.com/exyte/ScalingHeaderScrollView/blob/6afd9b32821b42c9dacb351c8ad8ca49f723ef1d/Source/ScalingHeaderScrollView.swift#L351C5-L351C5

This line of code in some situations returns nan instead of 0 which is not good. I suggest add a condition like:

private func getCollapseProgress() -> CGFloat {
    let result = 1 - min(max((getHeightForHeaderView() - minHeight) / (maxHeight - minHeight), 0), 1)
    
    if result.isNaN {
        return 0
    } else {
        return result
    }
}

or some another solution.

I haven't studied the code in depth but there is probably division by zero in some situation.

f3dm76 commented

Hey @petomuro, please check out version 1.0.2, should be fixed there. Have a wonderful day!