export const getScrollParent = function(element) { var parent = element.parentNode; if (!parent) { return element; } if (parent === document) { if (document.body.scrollTop !== undefined) { return document.body; } else { return document.documentElement; } } if ( ['scroll', 'auto'].indexOf( getStyleComputedProperty(parent, 'overflow') ) !== -1 || ['scroll', 'auto'].indexOf( getStyleComputedProperty(parent, 'overflow-x') ) !== -1 || ['scroll', 'auto'].indexOf( getStyleComputedProperty(parent, 'overflow-y') ) !== -1 ) { return parent; } return getScrollParent(element.parentNode); }; export const getStyleComputedProperty = function(element, property) { var css = window.getComputedStyle(element, null); return css[property]; };