4 ms·
A very cute bit of coding. But: I've always wondered who uses these "back to the top" buttons, and why? Until quite recently I hardly ever had reason to go ba
by cpcallen 5y ago
A very cute bit of coding.
But: I've always wondered who uses these "back to the top" buttons, and why?
Until quite recently I hardly ever had reason to go back to the top of the page—I was much more likely to click a link or click the back button—and if I did a quick tap of the home key or flick of the touchscreen usually did the trick. Conveniently, both gestures work even if you've not gotten all the way down to the "back to the top" button.
More recently with Chrome on iOS I find myself wanting to get to the top so I can use the pull-down-then-right gesture to close the tab. With really long pages sometimes a single flick isn't enough to get me all the way to the top—but then, on a really long page I'm also unlikely to have gotten all the way to the bottom.
- electroly 5y agoOn iOS, tap the top of the screen to automatically scroll to the top.
- mwexler 5y agoAnd is frustratingly, conspicuously missing in Android. Every time I switch to my Android tablet, it's becomes a hugely missing piece for any content consumption app that scrolls.
- Xenoamorphous 5y agoI think I read here on HN that Apple holds a patent for that functionality.
- ComputerGuru 5y agoExcept on AMP pages or on weird custom front ends. Long love plain html and css. Please don’t override the platform default scroll acceleration either!
- eyelidlessness 5y agoThis also works in most apps, unless they’re using some weird nonstandard UI (which is, perhaps surprisingly, less common on iOS than on macOS). And it works with Reachability. Neither of which are especially discoverable, but super handy if you know about them.
- frankfrankfrank 5y agoYeah, I wish there were a way to scroll to the bottom too, i.e., double-tap the top of the screen/bar. It would come in handy quite frequently for me.
- majewsky 5y agoOh THAT'S what that's supposed to be. I was always wondering why my viewport jumps all over the place unprompted.
- hinkley 5y agoThere's usually some combination of the Home key that does the same on most desktop browsers, but the control key varies by OS and sometimes browser. What there isn't on iOS as far as I'm aware is a way to scroll to the bottom. On infinite scroll pages accidentally navigating away as one can easily do with touch screen results in a lot of frustration.
- deleted 5y ago[deleted]
- sandreas 5y agoYeah, in the days where fixed nav at top is often used by default it is not as common to have TOP links any more. Recently I searched for a way to PREVENT going to the top clicking a link <a href="#" onclick="console.log(1)"> that only had JavaScript in it and always jumped back and forth due to AJAX page reload. The solution[1] I found was using <a href="#!" onclick="console.log(1)">A no jump link</a>. [1]https://pilabor.com/blog/2021/03/html-and-css-tricks/#no-jump-links-href https://pilabor.com/blog/2021/03/html-and-css-tricks/#no-jum...
- JadedBlueEyes 5y agoOn a slight tangent, links should not be used as buttons - please use a HTML button and style it with css. Links-as-buttons tend to interact poorly with things like opening in new tabs, and it's not the semantically correct use of the element anyway. > If clicking the link without javascript doesn't do anything without Javascript, it should be a `button` https://css-tricks.com/a-complete-guide-to-links-and-buttons/#buttons https://css-tricks.com/a-complete-guide-to-links-and-buttons...
- 8n4vidtmkvmk 5y agoYou can make the onclick event.preventDefault to prevent the scroll and adding hashtag to the URL
- jerf 5y agoI think back in Ye Olde Days it was harder for people who just had a scrollbar, and weren't necessarily all that familiar with that, either. There has never been a technical need for it. The "Home" keyboard button when pressed on a web page has taken you to the top probably since the very first web browser was released. But there's a lot of computer users for whom that entire complex of keys off to the right of Enter on a standard keyboard is The Outer Hinterlands, Where There Be Dragons, except for maybe the arrow keys. Also the entire line of function keys. Not everyone is an expert.
- unkulunkulu 5y agoReading your post I realized that I have not pressed a Home button for years. Now I have a strong Home button (and full sized keyboard in general) nostalgia and cannot sleep! I will just go ahead and press it next time I see a full sized keyboard I swear!
- theK 5y agoBtw on most crop keyboards home is mapped to Fn + Left Arrow. No need to dig up that old IBM keyboard :-)
- phailhaus 5y agoIt's more useful for mobile, where there isn't a "home" key and you'll often need to scroll back up to access menus/filters/etc.
- throwaway889900 5y agoOn a pull-to-refresh style widget, the scrollbar needs to be at the top. This provides a shortcut to jump to the top and refresh.
- dheera 5y agoI think it was more of a thing in a bygone era when scroll wheels and swiping didn't have that inertia effect to get you to the top efficiently. Nowadays you just swipe down fast once and the inertia gets you to the top but it used to once not be like that, and you had to thumb your screen 15 times to free solo your way to the top.