From aaf285b438a70ffc3a5a0bff12a70abe567bf14c Mon Sep 17 00:00:00 2001 From: Phil Banks Date: Wed, 20 Nov 2013 15:58:38 +0000 Subject: [PATCH] Add support for is a valid element within --- js/jquery.stickytableheaders.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/js/jquery.stickytableheaders.js b/js/jquery.stickytableheaders.js index 469e5a4..0f8dd46 100644 --- a/js/jquery.stickytableheaders.js +++ b/js/jquery.stickytableheaders.js @@ -41,7 +41,13 @@ // remove padding on
to fix issue #7 $this.css('padding', 0); - base.$originalHeader = $('thead:first', this); + // account for
element + if ($this.children(':first-child').is("caption")) { + base.$originalHeader = $('caption,thead:first', this); + } else { + base.$originalHeader = $('thead:first', this); + } + base.$clonedHeader = base.$originalHeader.clone(); base.$clonedHeader.addClass('tableFloatingHeader'); @@ -106,6 +112,11 @@ var newTopOffset = isNaN(base.options.fixedOffset) ? base.options.fixedOffset.height() : base.options.fixedOffset; + // account for + if ($this.children(':first-child').is("caption")) { + var captionOffset = newTopOffset + $this.children(':first-child').outerHeight(); + } + var offset = $this.offset(); var scrollTop = base.$window.scrollTop() + newTopOffset; var scrollLeft = base.$window.scrollLeft(); @@ -123,6 +134,12 @@ 'left': newLeft, 'z-index': 1 // #18: opacity bug }); + + // account for + $('thead, originalHeader').css({ + 'margin-top': captionOffset + }); + base.$clonedHeader.css('display', ''); base.isSticky = true; base.leftOffset = newLeft;