Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Copy scrollParent to be jQuery UI independent
  • Loading branch information
Danielku15 authored Aug 14, 2017
commit 861f1d706d7ed58e6c39ef779391c056392f95b9
30 changes: 28 additions & 2 deletions js/dataTables.fixedHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,32 @@ $.extend( FixedHeader.prototype, {
lastScrollLeft[ item ] = scrollLeft;
}
},

/**
* Get the closest ancestor element that is scrollable.
* @private
*/
_scrollParent: function( element )
{
// based on the jQuery UI version of scrollParent()
// Copyright jQuery Foundation and other contributors
// Released under the MIT license.
var position = element.css( "position" ),
excludeStaticParent = position === "absolute",
overflowRegex = /(auto|scroll)/,
scrollParent = element.parents().filter( function() {
var parent = $( this );
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
return false;
}
return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
parent.css( "overflow-x" ) );
} ).eq( 0 );

return position === "fixed" || !scrollParent.length ?
$( element[ 0 ].ownerDocument || document ) :
scrollParent;
},

/**
* Change from one display mode to another. Each fixed item can be in one
Expand Down Expand Up @@ -503,7 +529,7 @@ $.extend( FixedHeader.prototype, {
var position = this.s.position;
var dom = this.dom;
var tableNode = $(table.node());
var scrollParent = tableNode.scrollParent();
var scrollParent = this._scrollParent(tableNode);

// Need to use the header and footer that are in the main table,
// regardless of if they are clones, since they hold the positions we
Expand All @@ -520,7 +546,7 @@ $.extend( FixedHeader.prototype, {
position.theadHeight = position.tbodyTop - position.theadTop;
position.scrollParentTop = scrollParent.offset().top;
position.scrollParentVisible = scrollParent.is(':visible');
position.scrollParentHeight = scrollParent.outerHeight();
position.scrollParentHeight = scrollParent.outerHeight();

if ( tfoot.length ) {
position.tfootTop = tfoot.offset().top;
Expand Down