+}
+
+/**
+ * Find the closest scroll container parent for the given element
+ * otherwise will default to the body element.
+ */
+export function findClosestScrollContainer(start: HTMLElement): HTMLElement {
+ let el: HTMLElement|null = start;
+ do {
+ const computed = window.getComputedStyle(el);
+ if (computed.overflowY === 'scroll') {
+ return el;
+ }
+
+ el = el.parentElement;
+ } while (el);
+
+ return document.body;