Initial commit
This commit is contained in:
26
wwwroot/lib/popper.js/esm/dom-utils/listScrollParents.js
Normal file
26
wwwroot/lib/popper.js/esm/dom-utils/listScrollParents.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import getScrollParent from "./getScrollParent.js";
|
||||
import getParentNode from "./getParentNode.js";
|
||||
import getWindow from "./getWindow.js";
|
||||
import isScrollParent from "./isScrollParent.js";
|
||||
/*
|
||||
given a DOM element, return the list of all scroll parents, up the list of ancesors
|
||||
until we get to the top window object. This list is what we attach scroll listeners
|
||||
to, because if any of these parent elements scroll, we'll need to re-calculate the
|
||||
reference element's position.
|
||||
*/
|
||||
|
||||
export default function listScrollParents(element, list) {
|
||||
var _element$ownerDocumen;
|
||||
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
|
||||
var scrollParent = getScrollParent(element);
|
||||
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
||||
var win = getWindow(scrollParent);
|
||||
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
||||
var updatedList = list.concat(target);
|
||||
return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
||||
updatedList.concat(listScrollParents(getParentNode(target)));
|
||||
}
|
||||
Reference in New Issue
Block a user