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

add end option #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Make items sticky as you scroll, to a point. ([See Demo](http://davist11.github.
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>

<div class="aside stickem">
I'm gonna be sticky!
</div>
Expand Down Expand Up @@ -52,6 +52,9 @@ Do you already have a fixed horizontal header on the page? Offset stick 'em by t
**start: 0**<br>
If your sticky item isn't at the top of the container, tell it where it should start being sticky.

**end: 0**<br>
If your sticky item shouldn't stick exactly at the end of the container, tell it where it should end being sticky.

**onStick: null**<br>
You can create a callback function that fires when an item gets "stuck". The item gets passed back.

Expand All @@ -65,4 +68,4 @@ If you have a bunch of stuff that happens after your page has loaded (e.g. AJAX
<pre>var sticky = $('.container').stickem();
sticky.destroy();</pre>

Then you can re-instantiate again if you need to.
Then you can re-instantiate again if you need to.
3 changes: 2 additions & 1 deletion jquery.stickem.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
endStickClass: 'stickit-end',
offset: 0,
start: 0,
end: 0,
onStick: null,
onUnstick: null
},
Expand Down Expand Up @@ -89,7 +90,7 @@

item.containerInnerHeight = item.$container.height();
item.containerStart = item.$container.offset().top - _self.config.offset + _self.config.start + item.containerInner.padding.top + item.containerInner.border.top;
item.scrollFinish = item.containerStart - _self.config.start + (item.containerInnerHeight - item.elemHeight);
item.scrollFinish = item.containerStart - _self.config.start + (item.containerInnerHeight - item.elemHeight) + _self.config.end;

//If the element is smaller than the container
if(item.containerInnerHeight > item.elemHeight) {
Expand Down