i want a div2 to be placed to the left of div1. i have below method to do that..i pass alignment as 'left' and it returns x and y coordinates for it based on div1.
Below is the method,
const position_val = position(rect, 'right');
position = (rect, alignment) => {
     switch(alignment) {
        case 'left':
            return {x: rect.left - (this.props.start_offset || 0), y: rect.top + (rect.height / 2)};
        case 'top':
            return {x: rect.left + (rect.width / 2) , y: rect.top};
        case 'bottom':
            return {x: rect.left + (rect.width / 2), y: rect.bottom};
        case 'right':
            return {x: rect.right + (this.props.start_offset || 0), y:rect.top + (rect.height / 2)};
        default:
            return {x: (rect.left + rect.width / 2), y: rect.top + (rect.height / 2) + 
            (this.props.end_offset || 0)};
    }
from the above code case default and 'right' work well..however i am not sure where to offset_x and offset_y values in case left, top and bottom...
once the values are returned from position method i apply them to top and left of div2 element like below,
div2.style.top = position_val.y;
div2.style.left = position_val.x;
could someone help me fix this method to get correct values for case left, top and bottom. thanks.
 
    