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

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

merged 2 commits into from Mar 2, 2019

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

@andreivictor andreivictor commented Mar 2, 2019

Why closing it?

Loading

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

@WickyNilliams WickyNilliams commented Mar 2, 2019

Must have done it on accident, sorry!

Loading

@andreivictor
Copy link
Contributor Author

@andreivictor andreivictor commented Mar 2, 2019

No prob, thanks for your answer.

Loading

@WickyNilliams
Copy link
Owner

@WickyNilliams WickyNilliams 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?

Loading

@WickyNilliams WickyNilliams merged commit 3a5b0fe into WickyNilliams:master Mar 2, 2019
@andreivictor
Copy link
Contributor Author

@andreivictor andreivictor commented Mar 2, 2019

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

Loading

@WickyNilliams
Copy link
Owner

@WickyNilliams WickyNilliams 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.

Loading

@WickyNilliams
Copy link
Owner

@WickyNilliams WickyNilliams commented Mar 2, 2019

Just updating the readme would be more than enough.

Loading

@andreivictor
Copy link
Contributor Author

@andreivictor andreivictor commented Mar 3, 2019

Updated in #316. Thanks!

Loading

@WickyNilliams
Copy link
Owner

@WickyNilliams WickyNilliams commented Sep 11, 2019

Published to npm as v0.10.0 🎉

Loading

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

Successfully merging this pull request may close these issues.

None yet

3 participants