Skip to content
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
4 changes: 3 additions & 1 deletion js/jquery.stickytableheaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
if (base.$el) {
base.$el.each(function () {
var $this = $(this),
$bottom = $(base.options.bottom) || $this,
newLeft,
newTopOffset = base.isWindowScrolling ? (
isNaN(base.options.fixedOffset) ?
Expand All @@ -123,6 +124,7 @@
) :
base.$scrollableArea.offset().top + (!isNaN(base.options.fixedOffset) ? base.options.fixedOffset : 0),
offset = $this.offset(),
bottomOffset = $bottom.offset(),

scrollTop = base.$scrollableArea.scrollTop() + newTopOffset,
scrollLeft = base.$scrollableArea.scrollLeft(),
Expand All @@ -131,7 +133,7 @@
scrollTop > offset.top :
newTopOffset > offset.top,
notScrolledPastBottom = (base.isWindowScrolling ? scrollTop : 0) <
(offset.top + $this.height() - base.$clonedHeader.height() - (base.isWindowScrolling ? 0 : newTopOffset));
(bottomOffset.top + $bottom.height() - base.$clonedHeader.height() - (base.isWindowScrolling ? 0 : newTopOffset));

if (scrolledPastTop && notScrolledPastBottom) {
newLeft = offset.left - scrollLeft + base.options.leftOffset;
Expand Down
2 changes: 1 addition & 1 deletion js/jquery.stickytableheaders.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ $(window).trigger('resize.stickyTableHeaders');
###Options
You can initialize the plugin with an options map to tweak the behavior. The following options are supported:

####`bottom`
A DOM element or jQuery object. The sticky header will remain visible until scrolling past the bottom of the specified element instead of the bottom of the table:

```js
$('table').stickyTableHeaders({bottom: $('#another-table')});
```

####`fixedOffset`
A number or jQuery object specifying how much the sticky header should be offset from the top of the page:

Expand Down