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

Adding methods to freeze / unfreeze the current headroom's state. #309

Merged
merged 2 commits into from Mar 2, 2019

Conversation

@andreivictor
Copy link
Contributor

commented Jan 2, 2019

Inspired from another PR (#253), I've added methods to freeze and unfreeze the current headroom's state.

  • freeze method: When called, this method will freeze the current headroom's state (pinned or unpinned). Headroom will not react to the user's scroll. If you wish to re-enable the headroom's default behaviour, you can call unfreeze method.

  • unfreeze method: When called, this method will resume headroom's default behaviour. Headroom will pin or unpin when the user scrolls the page. By default, Headroom is not freezed and calling this method before freeze will do nothing.

There is also a new property - frozen - for the classes option:

{
  classes: {
    // ... other classes
    freezed : 'headroom--frozen'
  }
}

Usage:

var headroom  = new Headroom(myElement);
// initialise
headroom.init();

// freeze 
headroom.freeze();

// unfreeze
headroom.unfreeze();

Example:
https://codepen.io/andreivictor/pen/oymbLO

src/Headroom.js Outdated Show resolved Hide resolved
@andreivictor

This comment has been minimized.

Copy link
Contributor Author

commented Mar 2, 2019

Why closing it?

@WickyNilliams WickyNilliams reopened this Mar 2, 2019

@WickyNilliams

This comment has been minimized.

Copy link
Owner

commented Mar 2, 2019

Must have done it on accident, sorry!

@andreivictor

This comment has been minimized.

Copy link
Contributor Author

commented Mar 2, 2019

No prob, thanks for your answer.

@WickyNilliams

This comment has been minimized.

Copy link
Owner

commented Mar 2, 2019

This looks good to me, thanks @andreivictor. I'll get this merged now and try and work out a plan for release. I'll also need to update the docs. Unless you have a desire to do that also?

@WickyNilliams WickyNilliams merged commit 3a5b0fe into WickyNilliams:master Mar 2, 2019

@andreivictor

This comment has been minimized.

Copy link
Contributor Author

commented Mar 2, 2019

I will try to update the README.md file in this weekend. Is there another place to update?

@WickyNilliams

This comment has been minimized.

Copy link
Owner

commented Mar 2, 2019

Don't do it on the weekend if you don't want to, enjoy yourself instead!

There's also a website on the gh-pages branch, but it's been so long since I've had to update that, I'm not sure what state it is in.

@WickyNilliams

This comment has been minimized.

Copy link
Owner

commented Mar 2, 2019

Just updating the readme would be more than enough.

@andreivictor

This comment has been minimized.

Copy link
Contributor Author

commented Mar 3, 2019

Updated in #316. Thanks!

@WickyNilliams

This comment has been minimized.

Copy link
Owner

commented Sep 11, 2019

Published to npm as v0.10.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.