mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
StickyHeaders: only update class as needed. See #1018
This commit is contained in:
parent
4e54230321
commit
2854dc4340
@ -174,6 +174,7 @@
|
||||
scrollTop = attachTop + stickyOffset + nestedStickyTop - captionHeight,
|
||||
tableHeight = $table.height() - ($stickyWrap.height() + ($tfoot.height() || 0)) - captionHeight,
|
||||
isVisible = ( scrollTop > offset.top ) && ( scrollTop < offset.top + tableHeight ) ? 'visible' : 'hidden',
|
||||
state = isVisible === 'visible' ? ts.css.stickyVis : ts.css.stickyHide,
|
||||
cssSettings = { visibility : isVisible };
|
||||
if ($attach.length) {
|
||||
cssSettings.top = yWindow ? scrollTop - $attach.offset().top : $attach.scrollTop();
|
||||
@ -183,10 +184,13 @@
|
||||
cssSettings.left = $table.offset().left - parseInt($table.css('margin-left'), 10) - $xScroll.scrollLeft();
|
||||
}
|
||||
cssSettings.top = ( cssSettings.top || 0 ) + stickyOffset + nestedStickyTop;
|
||||
// attached sticky headers always need updating
|
||||
if ( !$stickyWrap.hasClass( state ) || $attach.length ) {
|
||||
$stickyWrap
|
||||
.removeClass( ts.css.stickyVis + ' ' + ts.css.stickyHide )
|
||||
.addClass( isVisible === 'visible' ? ts.css.stickyVis : ts.css.stickyHide )
|
||||
.addClass( state )
|
||||
.css(cssSettings);
|
||||
}
|
||||
if (isVisible !== laststate || resizing) {
|
||||
// make sure the column widths match
|
||||
resizeHeader();
|
||||
|
Loading…
Reference in New Issue
Block a user