Skip to content

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

Merged
WickyNilliams merged 2 commits intoWickyNilliams:masterfrom
andreivictor:master
Mar 2, 2019
Merged

Adding methods to freeze / unfreeze the current headroom's state.#309
WickyNilliams merged 2 commits intoWickyNilliams:masterfrom
andreivictor:master

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

@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 🎉

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