Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

responsive offset #257

Closed
Mohsen-Khakbiz opened this issue Dec 21, 2016 · 3 comments
Closed

responsive offset #257

Mohsen-Khakbiz opened this issue Dec 21, 2016 · 3 comments

Comments

@Mohsen-Khakbiz
Copy link

hey there,
thanks for this cool plugin.
I have an issue with responsive offset. can't update the offset on window resize.

I stored the offset value, that is height of an element, in a variable. and update that variable on window resize.
but the offset is what is set in the initial. and it won't change on window resize.

is there anything that I can do for this?

thanks

@WickyNilliams
Copy link
Owner

you should be able to simply set the offset property of your headroom instance:

var hr = new Headroom(element);
hr.init();

window.addEventListener("resize", function(e) {
  hr.offset = getOffsetValue();
}, false);

@mikemedoro
Copy link

I'm having trouble getting this to work. It seems to be returning the correct value on window resize but it's not getting applied to the headroom offset.

function getOffset() {
    let pageHeader = $('.post-header').outerHeight();
    return pageHeader;
}
const options = {
    offset: getOffset(),
}
const header = document.querySelector('.site-header');
const headroom = new Headroom(header, options);
headroom.init();

window.addEventListener('resize', function (e) {
    headroom.offset = getOffset();
    console.log(headroom.offset);
}, false);

@ABaier
Copy link

ABaier commented Jul 17, 2020

Same problem here. Did anybody achieve this in the end? Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants