Headhesive.js
An on-demand sticky header.
What is it?
Headhesive.js creates an on-demand sticky header. Specify when you want your header to become fixed and the rest is magic. View demo.
Install
Install with npm:
npm install headhesive
Install with Bower:
bower install headhesive (or bower install headhesive.js)
How to use?
Headhesive.js is a standalone JavaScript plugin with no dependencies. Include the headhesive.min.js
(from the dist/
folder) in the footer of your page and initialise it:
var header = new Headhesive('.header');
Styling Headhesive.js
Headhesive.js doesn't inject any CSS styles so you can use your own to completely control how your sticky element behaves. An example is provided in the demo.
Options
Customise how Headhesive.js works by passing in custom options.
var options = {
offset: 500
}
var header = new Headhesive('.header', options);
Defaults
{
offset: 300,
offsetSide: 'top',
classes: {
clone: 'headhesive',
stick: 'headhesive--stick',
unstick: 'headhesive--unstick'
},
throttle: 250,
onInit: function () {},
onStick: function () {},
onUnstick: function () {},
onDestroy: function () {},
}
Destroy method
To destroy an instance of Headhesive.js, you can call the destroy method:
header.destroy();
Browser support
IE9+ and modern browsers.
License
Headesive.js is licensed under the MIT License.
Demo
There is a demo available in the demo folder and online at http://markgoodyear.com/labs/headhesive/.