Skip to content

Instantly share code, notes, and snippets.

@interactivellama
Created November 9, 2015 20:31
Show Gist options
  • Select an option

  • Save interactivellama/3157d5bf8c0361d686b6 to your computer and use it in GitHub Desktop.

Select an option

Save interactivellama/3157d5bf8c0361d686b6 to your computer and use it in GitHub Desktop.
function _getContainer(element) {
var containerElement, isWindow;
// manual override
if (element.attr('data-target') && element.attr('data-target') !== 'window') {
containerElement = element.attr('data-target');
isWindow = false;
} else {
// default to window otherwise
containerElement = window;
isWindow = true;
if (!element.attr('data-target')) {
// 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),
isWindow: isWindow
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment