unction getTanDeg(deg) {
let rad = Math.tan(deg)
return rad * (180 / Math.PI)
}
function DrawLine(item, target) {
const targetX = target.offsetLeft + (target.getBoundingClientRect().width / 2);
const targetY = target.offsetTop + (target.getBoundingClientRect().height / 2);
const itemX = item.offsetLeft + (item.getBoundingClientRect().width / 2);
const itemY = item.offsetTop + (item.getBoundingClientRect().height / 2);
let trueHeight,
trueWidth, right, top, degI
if (itemY > targetY) {
trueHeight = itemY - targetY;
top = true;
} else {
trueHeight = targetY - itemY;
top = true;
}
if (itemX > targetX) {
trueWidth = itemX - targetX;
right = true;
} else {
trueWidth = targetX - itemX;
right = false;
}
let pifagor = Math.sqrt(trueWidth, + trueHeight);
if (right) {
if (top) {
degI = ''
} else {
degI = '-'
}
} else {
if (top) {
degI = '-'
} else {
degI = ''
}
}
console.log(itemY, targetY)
let deg = getTanDeg(trueHeight / pifagor)
target.querySelector('svg').style.transform = `translate(-50%,-50%) rotate(${degI + deg}deg) `