Fix header shrinking magic.

Shrink header when content is just about to become hidden, instead of after an entire paragraph is hidden.