Headroom.js – hide your header on scroll
wicky.nillia.ms
wicky.nillia.ms
I had been looking for this pattern's name after having seen Chrome on Android implementing it for their navbar. I find it useful on mobile where scrolling a long distance can be laborious.
They kept the data in a div with hidden overflow so you could alway see header and footer (not that useful for mobile).
But they also deleted old nodes when they were far enough away from the visible space in the div.
I've just stated a tautology, so I'm missing something.
EDIT I'm seriously wondering whether this whole thing is a joke I'm not getting. Is there a jQuery plug-in that lets me click on text to go to other pages, too?
Instead, when you begin to scroll to the top you can see the top. If you have an iphone, it's navbar behavior is identical to this.
Let's not be obtuse, yeah?
on the iPhone you can just double tap the top of the screen to scroll to the top quickly.
Which is all about browser chrome.Edit: it's not a joke, it's an established pattern found on both iOS and Android.
Slightly interesting backstory with android: this effect was originally added to the stock browser on android 3.0. I loved how the tiny enhancement gave me more screen real estate, so I decided to build a JS lib to emulate the effect. The pattern didn't make it into the original chrome for Android, but after I mentioned it to Paul Irish he made it happen there too :)
I've seen headers that stay on-screen while scrolling; even on huge displays they annoy me, so kudos to the author for the effort and putting it out there, but I can't help but feel like he just hit a windmill full tilt.
Edited to reduce inflammation.
Are there any stats that prove this? I see this repeated time and time again on HN but I'm yet to see evidence that (a meaningfully significant number of) users are turned off by headers like this, while I have seen evidence that it increases engagement rates. It's used in both Chrome on Android and Safari on iOS, so I don't think it's an alien concept at this point.
Really?
You're basically looking at picture #3 from the left: http://i0.wp.com/www.stephenblower.co.uk/wp-content/uploads/...
Do you need "stats" to prove the absurdity of headers that disappear when you scroll?
You made a claim about "users". Data to support it would be nice.
Downside: unusual behaviour. Users fully understand how to scroll to the top of a page to find the header. This hack already requires them to scroll up to get to the header. Also, there's a decent chance that if you're trying to find the header that you're going to leave the page, so it doesn't matter if you lose your spot.
It's a cutesy feature, but it's cumbersome and pointless, and doesn't add any real usability (unless you count getting rid of fixed headers, which also don't add any real usability).
In short, this element feels always somewhat out of user's control.
Much more usable on mobile would be putting such navigation in a kind of sidebar that many apps already employ (often accessible by swiping from the left edge of the screen), while on desktop a great solution is simple “top” links, strategically placed.
Plain fixed headers, possibly somewhat collapsing in height as you scroll, also seem better than vanishing headers from the point of control.
Unless there comes out some positive research on usability of this particular UI element, I personally am not convinced.
> Plain fixed headers, possibly somewhat collapsing in height as you scroll, also seem better than vanishing headers from the point of control.
That's doable with this library btw. What happens in response to scrolling is entirely dependent on your CSS. So when scrolling down, have it apply a class which reduces the height, and when scrolling up, restore the height.Also, it's worth noting, that whilst the obvious use-case for the lib is headers; it can be used on any element, to have it react to scroll direction and distance. For instance, I've used it to make a sidebar fixed after scrolling past a certain point on the page (classic sticky sidebar pattern). Also, I've used it to only show a "back to top" link when a user is > 50% down the page and scrolling up quickly - so unless you're deep in a page and scrolling towards the top, the link will never be visible/distracting.
It works well for these scenarios too!
There's no "Home" key on your phone that instantly takes you to the top of the page. Scrolling and scrolling and scrolling is annoying.
The main critique I have for the OP is that is that it should be responsive -- and only work on tablets and mobile
There is, at least on iOS. You can tap the status bar and it will quickly jump to the top of the page.
On iOS: tap on the system menu at the very top of the screen.
All it does is add and remove classes. It can be as responsive or unresponsive as you like with @media rules.
Does anyone know any sites which are devoted to curating high-quality repos on github/elsewhere¹? Obviously high quality is a subjective metric, but some mix of popularity, file size, whether under active development, number of issues etc. should suffice. GitHub's explore feature is too time-sensitive to use for this purpose.
¹ I know there's unheap.com, but that's focussed specifically on jQuery plugins. I'm thinking something broader, any language, different parts of the stack etc
[0] https://developer.apple.com/library/safari/documentation/app...
However, my plan has always been to trim the fat for the next release. I won't drop any features, but I'll definitely drop bytes! Feel free to fork and strip out any code you don't need though
http://stackoverflow.com/questions/20648451/how-do-you-use-h...
I had got as far as including animate.css in trying to get things working and I was just about to write here about how it didn't bl00%y work!!! All is working now, thanks for your well-spotted tip.
Isn't that what scrolling does? :)
> I admit, it's quite genius. And I bet that if Apple could, they would have patented it.
The effect is exacerbated on mobile devices whose browser chrome follows this very same idiom (for arguably better reasons - at least it's not buggy). So you now have two "competing" user interface effects.
I like that it is not a jQuery plugin by default, but does provide the option. Even better (for me) is an Angular directive ready for immediate integration.
Well done and keep up the good work!
By the way, I'm not an angular user, the directive was added through a PR. If you hit any problems or have any suggestions to improve it, please get in touch on github!
[0] https://github.com/WickyNilliams/headroom.js/blob/master/src...
I don't get the point of this, you get pretty much the same thing by doing nothing. Fix the menu to the top of the page, when you scroll down it goes away, scroll back up and there it is. Almost no one is going to care that they'll need to scroll back to the top, I'm sure of it.
</rant mode="full">
Now the town had a cat problem. They imported a large number of dogs, and soon the rats were gone. But now they had a dog problem.
The town imported a large number of lions...
A couple of years ago, when fixed headers became "cool", I'd write scripts for Greasemonkey just to get rid of them. Today I'm too lazy for that :D.
But nice project.
Cool effect for desktop but if you can get it working as a responsive solution I think it would be a lot more useful to people!
IIRC, you reduce the tolerance value (an options you can pass to headroom) it will work on iOS also, it just isn't quite as sensitive as it should be. I'm waiting for my development iPhone to charge so I can confirm this. I'll report back :)
Perhaps you could make it work (albeit less gracefully) in iOS by reconciling the header visibility state once "touchend" finally gets fired though? Assuming "touchstart" gets fired as you'd expect, you can do a bit of manual calculation to determine if the y-position changed enough to warrant header hide/show.
However, now that I have an iOS device (which is still charging!), I should spend some time seeing if I can get it to work better there. I'll look at various touch events as you suggest. Currently it only listens to the scroll event
Edit: version 4.2 Android Browser. I scrolled a good enough distance down the page.
Minor tweak will be to allow swiping from top to show it or when user moves mouse to top.