UNPKG

react-beautiful-dnd

Version:

Beautiful, accessible drag and drop for lists with React.js

27 lines (21 loc) 615 B
// @flow const isScrollable = (...values: string[]): boolean => values.some( (value: string): boolean => value === 'auto' || value === 'scroll', ); const isElementScrollable = (el: Element) => { const style = window.getComputedStyle(el); return isScrollable(style.overflow, style.overflowY, style.overflowX); }; const getClosestScrollable = (el: ?Element): ?Element => { // cannot do anything else! if (el == null) { return null; } if (!isElementScrollable(el)) { return getClosestScrollable(el.parentElement); } // success! return el; }; export default getClosestScrollable;