Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
get scrollParentsOffset () {
const parents = getScrollParents(this.node)
let offsetY = 0
let offsetX = 0
for (let i = 1; i < parents.length; i++) {
const parent = parents[i]
const child = parents[i - 1]
offsetY = offsetY + (this.normalizeScrollTop(parent) - this.normalizeScrollTop(child))
offsetX = offsetX + (parent.scrollLeft - child.scrollLeft)
}
return { top: offsetY, left: offsetX }
}
if (!element || placement === 'offscreen') return
this.container = container || ownerDocument(element).body
this.element = new PositionedElement(element, placement, { top: this.options.offsetY, left: this.options.offsetX })
this.target = new PositionedElement(
target || this.container,
over ? this.element.placement : this.element.mirroredPlacement
)
if (constrain === 'window') {
this.constrainTo(ownerWindow(element))
} else if (constrain === 'scroll-parent') {
this.constrainTo(getScrollParents(this.target.node)[0])
} else if (constrain === 'parent') {
this.constrainTo(this.container)
} else if (typeof constrain === 'function') {
this.constrainTo(findDOMNode(constrain.call(null)))
} else if (typeof constrain === 'object') {
this.constrainTo(findDOMNode(constrain))
}
}