Fixing affix logic for when the element being measured is near the top of the screen