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
Merged

Conversation

andreivictor
Copy link
Contributor

@andreivictor andreivictor 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
Copy link
Contributor Author

Why closing it?

@WickyNilliams WickyNilliams reopened this Mar 2, 2019
@WickyNilliams
Copy link
Owner

Must have done it on accident, sorry!

@andreivictor
Copy link
Contributor Author

No prob, thanks for your answer.

@WickyNilliams
Copy link
Owner

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
Copy link
Contributor Author

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

@WickyNilliams
Copy link
Owner

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
Copy link
Owner

Just updating the readme would be more than enough.

@andreivictor
Copy link
Contributor Author

Updated in #316. Thanks!

@WickyNilliams
Copy link
Owner

Published to npm as v0.10.0 🎉

This pull request was closed.
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

Successfully merging this pull request may close these issues.

3 participants