Show icon when scrolling down and hide scrolling up

Creating a simple to the top icon which fades in 50% down the page.
How do I make it fade out when scrolling up the page again.
Currently it stays visible/static.

/Dan