My client wants to have zoom functionality (I found that this is easy to implement with transform: scale()
but after that he wants to have the top-left edge of a node at the same position. Sadly in school instead of math I played to WarCraft III and Space Rangers (iconic Russian game, try it), so now I do not know what kind of formula I need :(
Another zoom position: as you see at the left we have empty "margin":
Minimum reproducible example is here:
const p = document.querySelector('p');
for (let i = 0; i < 50; i++) {
p.innerText += ' ' + Math.random() + Math.random();
}
document.querySelector('input').onchange = event => {
p.style.setProperty('--zoom', event.target.value);
}
input {
z-index: 1;
position: absolute;
}
p {
transform: matrix(
calc(var(--zoom) / 100),
0,
0,
calc(var(--zoom) / 100),
/* Next two lines is not perfect, what I need to write here? */
calc(var(--zoom) * var(--zoom) / 65 - 140),
calc(var(--zoom) * var(--zoom) / 1000)
);
}
<input type='range' min='10' max='200'></input>
<p></p>