all files / popper/utils/ getPosition.js

100% Statements 3/3
100% Branches 2/2
100% Functions 1/1
100% Lines 3/3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19                      296×       296× 296×    
import getOffsetParent from './getOffsetParent';
import isFixed from './isFixed';
 
/**
 * Helper used to get the position which will be applied to the popper
 * @method
 * @memberof Popper.Utils
 * @param config {HTMLElement} popper element
 * @returns {HTMLElement} reference element
 */
export default function getPosition(element) {
    const container = getOffsetParent(element);
 
    // Decide if the popper will be fixed
    // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
    const isParentFixed = isFixed(container);
    return isParentFixed ? 'fixed' : 'absolute';
}