Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1602 from interactivellama/auto-flip-parent
Browse files Browse the repository at this point in the history
Allow manual override for auto-flip dropdown menu
  • Loading branch information
swilliamset committed Nov 9, 2015
2 parents fc893cf + 5444cdd commit d3d497f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions js/dropdown-autoflip.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,26 @@

function _getContainer(element) {
var containerElement, isWindow;

// manual override
if (element.attr('data-target')) {
containerElement = element.attr('data-target');
isWindow = false;
} else {
// default to window otherwise
containerElement = window;
isWindow = true;
}

$.each(element.parents(), function (index, value) {
if ($(value).css('overflow') !== 'visible') {
containerElement = value;
isWindow = false;
return false;
}
});
// unless there's a parent element with non-visible overflow
$.each(element.parents(), function (index, value) {
if ($(value).css('overflow') !== 'visible') {
containerElement = value;
isWindow = false;
return false;
}
});

}

return {
overflowElement: $(containerElement),
Expand Down

0 comments on commit d3d497f

Please sign in to comment.