WickyNilliams / headroom.js

Give your pages some headroom. Hide your header until you need it
https://wicky.nillia.ms/headroom.js/
MIT License
10.86k stars 824 forks source link

Add support for 'rem' units instead of 'px' #368

Closed daattali closed 4 years ago

daattali commented 4 years ago

This may not make sense or be feasible, but with the new best practices of using rem instead of px for spacing elements, would it make sense to allow rem to be used to specify offset/tolerance/etc?

My header is defined in rem, just as the rest of my page. It feels a bit dirty to mix in px from headroom alongside. Perhaps this doesn't make sense for headroom though.

WickyNilliams commented 4 years ago

I don't think it makes a whole heap of sense for this library. Scroll position is always measured in pixels, so it makes sense for headroom to speak that language.

You could of course write a function to do any conversion math for you, if you wanted to be able to supply relative units. But headroom itself will stick with pixels for the time being.

Thanks for the suggestion anyway, appreciate it!