StickyHeaders: Include caption height in calculations. Fixes #1205

This commit is contained in:
Rob Garrison 2016-04-30 08:30:18 -05:00
parent a7abfa4e11
commit 0ad959531c
No known key found for this signature in database
GPG Key ID: 0A42D160D71978E1
3 changed files with 9 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -58,7 +58,8 @@ Note:
<!-- Tablesorter script: required -->
<script src="../js/jquery.tablesorter.js"></script>
<script src="../js/jquery.tablesorter.widgets.js"></script>
<script src="../js/widgets/widget-filter.js"></script>
<script src="../js/widgets/widget-stickyHeaders.js"></script>
<script id="js">$(function(){

View File

@ -162,12 +162,14 @@
var offset = $table.offset(),
yWindow = $.isWindow( $yScroll[0] ), // $.isWindow needs jQuery 1.4.3
xWindow = $.isWindow( $xScroll[0] ),
// scrollTop = ( $attach.length ? $attach.offset().top : $yScroll.scrollTop() ) + stickyOffset + nestedStickyTop,
scrollTop = ( $attach.length ? ( yWindow ? $yScroll.scrollTop() : $yScroll.offset().top ) : $yScroll.scrollTop() ) + stickyOffset + nestedStickyTop,
tableHeight = $table.height() - ($stickyWrap.height() + ($tfoot.height() || 0)),
attachTop = $attach.length ?
( yWindow ? $yScroll.scrollTop() : $yScroll.offset().top ) :
$yScroll.scrollTop(),
captionHeight = wo.stickyHeaders_includeCaption ? 0 : $table.children( 'caption' ).height() || 0,
scrollTop = attachTop + stickyOffset + nestedStickyTop - captionHeight,
tableHeight = $table.height() - ($stickyWrap.height() + ($tfoot.height() || 0)) - captionHeight,
isVisible = ( scrollTop > offset.top ) && ( scrollTop < offset.top + tableHeight ) ? 'visible' : 'hidden',
cssSettings = { visibility : isVisible };
if ($attach.length) {
cssSettings.top = yWindow ? scrollTop - $attach.offset().top : $attach.scrollTop();
}