Nav Bar change BG Color when scrolled up to top?

Hello, so currently I have a navbar with a transparent background that changes to black when the page is scrolled. However, when you scroll back to the top it stays black.

How would I get it to change back to transparent when the Hero is in the viewpoint?