in src/component/popup/popup/Popup.ts [512:547]
private _normalizeOffset(offset: number | PopupOffset): { [key in PopupAlignment]: number[] } {
if (offset == null) {
return this._normalizeOffset(0);
}
if (typeof offset === "number") {
// input specifies a radius
const sideOffset: number = <number>offset;
const sign: number = sideOffset >= 0 ? 1 : -1;
const cornerOffset: number = sign * Math.round(Math.sqrt(0.5 * Math.pow(sideOffset, 2)));
return {
"bottom": [0, sideOffset],
"bottom-left": [-cornerOffset, cornerOffset],
"bottom-right": [cornerOffset, cornerOffset],
"center": [0, 0],
"left": [-sideOffset, 0],
"right": [sideOffset, 0],
"top": [0, -sideOffset],
"top-left": [-cornerOffset, -cornerOffset],
"top-right": [cornerOffset, -cornerOffset],
};
} else {
// input specifes a value for each position
return {
"bottom": offset.bottom || [0, 0],
"bottom-left": offset.bottomLeft || [0, 0],
"bottom-right": offset.bottomRight || [0, 0],
"center": offset.center || [0, 0],
"left": offset.left || [0, 0],
"right": offset.right || [0, 0],
"top": offset.top || [0, 0],
"top-left": offset.topLeft || [0, 0],
"top-right": offset.topRight || [0, 0],
};
}
}