Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/benmills/jquery-stick
Stick an element in place as you scroll past it
https://github.com/benmills/jquery-stick
Last synced: about 1 month ago
JSON representation
Stick an element in place as you scroll past it
- Host: GitHub
- URL: https://github.com/benmills/jquery-stick
- Owner: benmills
- License: mit
- Created: 2011-04-07T20:39:55.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-07-17T14:14:41.000Z (over 12 years ago)
- Last Synced: 2024-04-17T02:56:28.543Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 102 KB
- Stars: 16
- Watchers: 5
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
- License: MIT-license.txt
Awesome Lists containing this project
README
# jQuery Stick
Stick is a simple plugin that will make an element stick in place as you scroll
```javascript
$('#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:
```javascript
$("#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:
```javascript
$("#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](http://www.braintreepayments.com/docs/ruby). 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