UNPKG

infogo-tree

Version:

A vue tree component using virtual list.

40 lines (35 loc) 1.36 kB
function getStyleComputedProperty(element: any, property: any) { // NOTE: 1 DOM access here const css = window.getComputedStyle(element, null) return css[property] } const getScrollParent: any = (element: any) => { const parent = element.parentNode if (!parent) { return element } if (parent === window.document) { // Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is // greater than 0 and return the proper element if (window.document.body.scrollTop || window.document.body.scrollLeft) { return window.document.body } else { return window.document.documentElement } } // Firefox want us to check `-x` and `-y` variations as well if ( ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-x')) !== -1 || ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-y')) !== -1 ) { // If the detected scrollParent is body, we perform an additional check on its parentNode // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise // fixes issue #65 return parent } return getScrollParent(element.parentNode) } export { getScrollParent, }