Skip to content

Commit

Permalink
Core: provide "includeHidden" parameter in $.ui.scrollParent
Browse files Browse the repository at this point in the history
Even though the user is unable to scroll via the UI, authors
may have custom scrollbars that programmatically set scrollTop.
Therefore, overflow:hidden can be considered a scrollParent.
  • Loading branch information
mikesherov committed Aug 12, 2014
1 parent 2ac0769 commit 67e4b44
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ui/core.js
Expand Up @@ -48,15 +48,16 @@ $.extend( $.ui, {

// plugins
$.fn.extend({
scrollParent: function() {
scrollParent: function( includeHidden ) {
var position = this.css( "position" ),
excludeStaticParent = position === "absolute",
overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
scrollParent = this.parents().filter( function() {
var parent = $( this );
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
return false;
}
return (/(auto|scroll)/).test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
}).eq( 0 );

return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
Expand Down

0 comments on commit 67e4b44

Please sign in to comment.