JSFiddle - React, Tailwind, and code Playground
by luka kupunia
HTML
<div id="test"></div>
<div id="test2"></div>
CSS
body {
margin: 0;
overflow: hidden;
}
*{
box-sizing: border-box;
}
div#test {
width: 100px;
height: 100px;
background: red;
animation: a linear 5s infinite;
transform-origin: top left;
transform: scale(1);
}
@keyframes a {
50% {
transform: scale(3);
}
100% {
transform: scale(1);
}
}
div#test2 {
width: 100px;
height: 100px;
background: blue;
float: right;
}
JavaScript
var a = document.querySelector('#test');
var elem = document.querySelector('#test2');
var matrixRegex = /matrix\((-?\d*\.?\d+),\s*0,\s*0,\s*(-?\d*\.?\d+),\s*0,\s*0\)/;
function fn(){
var b = window.getComputedStyle(a).getPropertyValue('transform').match(matrixRegex)[1]
elem.style.transform = 'scale(' + ( b ) + ')';
requestAnimationFrame(fn)
}
fn();