Hide header or some div on scroll

As the title says, how to acheive to hide the header or floating button if scroll down and bring back in if user scrolls up.