handle visibility correctly when there is no animation
Math.max fails on NaNs