Skip to content

Commit

Permalink
Added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Zivolo committed Apr 14, 2017
1 parent 9eff0af commit 3646636
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/popper/utils/findCommonOffsetParent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import isOffsetContainer from './isOffsetContainer';
import getRoot from './getRoot';

/**
* Finds the offset parent common to the two provided nodes
* @method
* @memberof Popper.Utils
* @argument {Element} element1
* @argument {Element} element2
* @returns {Element} common offset parent
*/
export default function findCommonOffsetParent(element1, element2) {
const range = document.createRange();
// This check is needed to avoid errors in case one of the elements isn't defined for any reason
Expand Down
7 changes: 7 additions & 0 deletions src/popper/utils/getRoot.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Finds the root node (document, shadowDOM root) of the given element
* @method
* @memberof Popper.Utils
* @argument {Element} node
* @returns {Element} root node
*/
export default function getRoot(node) {
if (node.parentNode !== null) {
return getRoot(node.parentNode);
Expand Down
8 changes: 8 additions & 0 deletions src/popper/utils/getScroll.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Gets the scroll value of the given element in the given side (top and left)
* @method
* @memberof Popper.Utils
* @argument {Element} element
* @argument {String} side `top` or `left`
* @returns {Number} amount of scrolled pixels
*/
export default function getScroll(element, side = 'top') {
const upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
const nodeName = element.nodeName;
Expand Down
10 changes: 10 additions & 0 deletions src/popper/utils/getTotalScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import getParentNode from './getParentNode';
import isOffsetContainer from './isOffsetContainer';
import isFixed from './isFixed';

/**
* Gets the scroll value of the given element relative to the given parent/
* It will not include the scroll values of elements that aren't positioned.
* @method
* @memberof Popper.Utils
* @argument {Element} element
* @argument {Element} parent
* @argument {String} side `top` or `left`
* @returns {Number} amount of scrolled pixels
*/
export default function getTotalScroll(element, parent, side = 'top') {
const scrollParent = getScrollParent(element);
let scroll = 0;
Expand Down

0 comments on commit 3646636

Please sign in to comment.