I recently had the need to float one of my site’s static top menu, but only when someone scrolled down. I needed it to work on both desktop and touch devices like iPhones/iPads, etc.
The most common solution I found utilized the window’s scroll event:
This worked (for the most part). However on touch devices, the event would not trigger until the scrolling was completely finished. Which caused a visible lag on most touch devices while it waited for the swiped scroll to slow down and stop.