( resizing )
| 2347 | setWidth( $header, $stickyCells ); |
| 2348 | }, |
| 2349 | scrollSticky = function( resizing ) { |
| 2350 | if (!$table.is(':visible')) { return; } // fixes #278 |
| 2351 | // Detect nested tables - fixes #724 |
| 2352 | nestedStickyTop = $nestedSticky.length ? $nestedSticky.offset().top - $yScroll.scrollTop() + $nestedSticky.height() : 0; |
| 2353 | var offset = $table.offset(), |
| 2354 | yWindow = $.isWindow( $yScroll[0] ), // $.isWindow needs jQuery 1.4.3 |
| 2355 | xWindow = $.isWindow( $xScroll[0] ), |
| 2356 | // scrollTop = ( $attach.length ? $attach.offset().top : $yScroll.scrollTop() ) + stickyOffset + nestedStickyTop, |
| 2357 | scrollTop = ( $attach.length ? ( yWindow ? $yScroll.scrollTop() : $yScroll.offset().top ) : $yScroll.scrollTop() ) + stickyOffset + nestedStickyTop, |
| 2358 | tableHeight = $table.height() - ($stickyWrap.height() + ($tfoot.height() || 0)), |
| 2359 | isVisible = ( scrollTop > offset.top ) && ( scrollTop < offset.top + tableHeight ) ? 'visible' : 'hidden', |
| 2360 | cssSettings = { visibility : isVisible }; |
| 2361 | |
| 2362 | if ($attach.length) { |
| 2363 | cssSettings.top = yWindow ? scrollTop - $attach.offset().top : $attach.scrollTop(); |
| 2364 | } |
| 2365 | if (xWindow) { |
| 2366 | // adjust when scrolling horizontally - fixes issue #143 |
| 2367 | cssSettings.left = $table.offset().left - parseInt($table.css('margin-left'), 10) - $xScroll.scrollLeft() - spacing; |
| 2368 | } |
| 2369 | if ($nestedSticky.length) { |
| 2370 | cssSettings.top = ( cssSettings.top || 0 ) + stickyOffset + nestedStickyTop; |
| 2371 | } |
| 2372 | $stickyWrap |
| 2373 | .removeClass( ts.css.stickyVis + ' ' + ts.css.stickyHide ) |
| 2374 | .addClass( isVisible === 'visible' ? ts.css.stickyVis : ts.css.stickyHide ) |
| 2375 | .css(cssSettings); |
| 2376 | if (isVisible !== laststate || resizing) { |
| 2377 | // make sure the column widths match |
| 2378 | resizeHeader(); |
| 2379 | laststate = isVisible; |
| 2380 | } |
| 2381 | }; |
| 2382 | // only add a position relative if a position isn't already defined |
| 2383 | if ($attach.length && !$attach.css('position')) { |
| 2384 | $attach.css('position', 'relative'); |
no test coverage detected