Moving maxHeight check outside of the animation block.