So I have a container that I want to scale up and down (zoom in and out) but to also have its expanded/shrunk form to take up space rather than just overlapping other stuff.
Edit: sorry rushed it, I meant update the container
You can, add a container. Store the initial size of this container. Now when you scale in the inner element, update the container width/height to the same ratio.
var a = document.getElementById("outer-wrapper");
var b = document.getElementById("outer");
var scale = 1;
var aWidth = a.offsetWidth;
var aHeight = a.offsetHeight;
function increase()
{
scale += 0.1
b.style.transform = `scale(${scale})`;
a.style.width = `${scale * aWidth}px`;
a.style.height = `${scale * aHeight}px`;
}
function decrease()
{
scale -= 0.1
b.style.transform = `scale(${scale})`;
a.style.width = `${scale * aWidth}px`;
a.style.height = `${scale * aHeight}px`;
}
#outer {
position: relative;
transform-origin: left top;
}
.pointer {
width: 20px;
height: 20px;
background-color: orange;
position: absolute;
}
#a1 {
top: 50px;
left: 150px;
}
#a2 {
top: 150px;
left: 50px;
}
#a3 {
top: 250px;
left: 550px;
}
please don't cover me