@nexara/nativeflow
Version:
Beautiful, responsive, and customizable UI components for React Native – built for performance and seamless experiences.
31 lines (29 loc) • 1.02 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.positionCalculations = void 0;
const positionCalculations = (anchorLayoutRef, menuLayoutRef, placement) => {
let positionValues = {
top: 0,
bottom: 0,
left: 0,
right: 0
};
if (anchorLayoutRef.pageX < menuLayoutRef.width) {
positionValues.left = anchorLayoutRef.pageX + anchorLayoutRef.width;
} else {
positionValues.left = anchorLayoutRef.pageX - menuLayoutRef.width;
}
// else if (anchorLayoutRef.current.pageX + menuLayoutRef.current.width > SCREEN_WIDTH) {
// positionValues.left = anchorLayoutRef.current.pageX - menuLayoutRef.current.width;
// }
if (placement === 'top') {
positionValues.top = anchorLayoutRef.pageY;
} else if (placement === 'bottom') {
positionValues.top = anchorLayoutRef.pageY - menuLayoutRef.height + anchorLayoutRef.height;
}
return positionValues;
};
exports.positionCalculations = positionCalculations;
//# sourceMappingURL=calculations.js.map
;