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

Using separate up/down offset values introduced a bug with the top and notTop classes behaviour #377

Open luksak opened 3 years ago

luksak commented 3 years ago

Using separate up/down offset values breaks removal of the notTop class and the addition of the top class.

To reproduce this issue set different top and bottom offsets. Scrolling down and back up leaves the headroom--not-top and doesn't add the headroom--top class on the element.

Here is the code I am using:

const options = {
  offset: {
    up: 150,
    down: 40,
  },
  useTouchmove: true,
}
headroomInstance = new Headroom(document.body, options);
headroomInstance.init();

I can reproduce this behavior in Firefox and Chrome.