I am trying to animate a div that changes size and location at the same time. I achieved it through the transition property in chrome but it does not in safari. It seems in safari that the transform: translate(50%, 50%);
property does not evaluate the width and height properties as they are both transitioning. I'm running my code on JsFiddle. My html is simply a span <span class="square" id="square"> </span>
My CSS:
.square {
background-color: red;
transition: all 1s;
cursor: pointer;
position: absolute;
width: 10rem;
height: 10rem;
transform: translate(0, 0);
}
.square-expanded {
width: 20rem;
height: 20rem;
transform: translate(50%, 50%);
}
My javaScript:
var square = document.getElementById("square");
square.addEventListener("click", moveSquare);
function moveSquare() {
square.classList.toggle('square-expanded');
}
I've tried using the -webkit prefix for Safari but it has made no difference. The animation is still broken. I also tried using proper CSS animation instead of transitions but nothing.
Thanks for reading.