UNPKG

@guruhotel/aura-hooks

Version:

🪝 Hooks library designed by the Guruhotel team for Aura UI

1 lines 802 B
exports.__esModule=!0,exports.getRelativePosition=void 0;exports.getRelativePosition=({axis:t,target:e,parent:n,alignment:i,offset:r,isList:o})=>{if(!e||!n&&"undefined"==typeof document)return 0;const s=!!n,d=(n||document.body).getBoundingClientRect(),h=e.getBoundingClientRect(),u=t=>h[t]-d[t];if("y"===t){const t=u("top");if(0===t)return 0;if("start"===i){const e=t-r;return e<=h.height*(o?0:1)||!o?e:0}const e=s?d.height:window.innerHeight;if("end"===i){const n=t+r-e+h.height;return n>=-h.height*(o?0:1)||!o?n:0}return"center"===i?t-e/2+h.height/2:0}if("x"===t){const t=u("left");if(0===t)return 0;if("start"===i){const e=t-r;return e<=h.width||!o?e:0}const e=s?d.width:window.innerWidth;if("end"===i){const n=t+r-e+h.width;return n>=-h.width||!o?n:0}return"center"===i?t-e/2+h.width/2:0}return 0};