There is a plugin that detects when something is on screen
Somebody posted about how to use this for your use case in the past