I don't think it's about the proximity to the border. The bug jumps when the screen scrolls while the bug is in its version of the taking damage animation.