As I can get position of element from left side of screen using e.getBoundingClientRect().left
When we want to get the position of end points then add width or height according to need but how to get the position of end points when element is rotated.
Is it possible to get values
let getBoxPos = document.querySelectorAll(".demo")
let box1 = document.querySelector("#box1")
let box2 = document.querySelector("#box2")
let box3 = document.querySelector("#box3")
let s = "";
function func() {
getBoxPos.forEach(e => {
let figXValue = e.getBoundingClientRect().left;
s = Number(s) + Number(1);
console.log("Start distance for box" + s + ":" + figXValue)
})
console.log("End distance for box1:" + (box1.getBoundingClientRect().left + 24));
console.log("End distance for box3:" + (box3.getBoundingClientRect().left + 104));
console.log("Don't know the correct way for box2:Is it box2.getBoundingClientRect().left + 100 or box2.getBoundingClientRect().left + 20 or none of them ");
}
func();
.demo {
height: 100px;
width: 20px;
margin-left: 40px;
border: 2px solid black;
}
.demo:nth-child(2) {
border: 2px solid red;
transform: rotate(-45deg);
}
.demo:nth-child(3) {
border: 2px solid green;
transform: rotate(-90deg);
}
<div class="demo" id="box1"></div>
<div class="demo" id="box2"></div>
<div class="demo" id="box3"></div>