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

--pinned and --unpinned is not added in latest release(s) #360

Closed dakur closed 4 years ago

dakur commented 4 years ago

It worked in 0.9.4, but no more – neither in 0.10.4 nor in 0.11.0. Do I miss something?

Code:

import Headroom from 'headroom.js';

const menuElement = document.getElementById('menuBar');
const headroom = new Headroom(menuElement, {
    tolerance: {
        up: 50,
    },
});
headroom.init();

No custom class selectors, ran on DOMContentLoaded, --not-top etc. are added as they should be.

image

WickyNilliams commented 4 years ago

Hmm... I'm surprised this ever worked. It is intended that you specify both up and down values when passing an object for tolerance. If you do that, everything should work:

import Headroom from 'headroom.js';

const menuElement = document.getElementById('menuBar');
const headroom = new Headroom(menuElement, {
    tolerance: {
        up: 50,
        down: 0,
    },
});
headroom.init();

See a working example here: https://codepen.io/WickyNilliams/pen/zYOLbqK?editors=0010

WickyNilliams commented 4 years ago

I should really add some TS typings to the library to help with stuff like this.

dakur commented 4 years ago

I was expecting that modifying only one of those options will leave the second one to default. Thank you for clarification. TS typings would definitely prevent this. :-)