Skip to content

benmills/jquery-stick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery Stick

Stick is a simple plugin that will make an element stick in place as you scroll

$('#menu').stick();

Options

There are only a few options:

  • offset: the distance from the top of the screen the element should be.
  • onStick: a callback for when the element sticks.
  • onUnstick: a callback when the element stops being sticky.

You can set the options by passing in an object:

$("#menu").stick({
  offset: 10,
  onStick: function () {},
  onUnstick: function () {}
});

As a shortcut, you can pass an integer in and jquery-stick will use that as the offset value:

$("#menu").stick(10);

Examples

This plugin was made when I couldn't find a simple enough existing jquery plugin while I was building the latest version of Braintree's documentation site. In this site I'm sticking two different elements, the sidebar menu and the top menu.

License

Copyright (c) 2011 Ben Mills Licensed under the MIT license

About

Stick an element in place as you scroll past it

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published