Skip to content

Commit

Permalink
Merge pull request #1119 from mreinstein/master
Browse files Browse the repository at this point in the history
add some documentation on getOffsetParent and listScrollParents
  • Loading branch information
FezVrasta committed May 31, 2020
2 parents 638fd00 + 941353f commit 422b69d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dom-utils/getOffsetParent.js
Expand Up @@ -17,6 +17,10 @@ function getTrueOffsetParent(element: Element): ?Element {
return element.offsetParent;
}

/*
get the closest ancestor positioned element. Handles some edge cases,
such as table ancestors and cross browser bugs.
*/
export default function getOffsetParent(element: Element) {
const window = getWindow(element);

Expand Down
6 changes: 6 additions & 0 deletions src/dom-utils/listScrollParents.js
Expand Up @@ -6,6 +6,12 @@ import getWindow from './getWindow';
import type { Window, VisualViewport } from '../types';
import isScrollParent from './isScrollParent';

/*
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: Node,
list: Array<Element | Window> = []
Expand Down

0 comments on commit 422b69d

Please sign in to comment.