The rotation animation is working. The size of the image is changing, but the translation of the image is not working at all. I'm not sure why and I tried it separately, and it still wouldn't work. I've also looked at a dozen examples of other people translating their items including examples on codepen. My code is almost exact, yet it does not produce any results. Why is this happening and how can I fix it?
Thanks for any advice or help.
$("#toolbar").on("click", function() {
const speed = 500;
if ($('#toolbar').css("width") == "75px") {
$('#toolbar').css("transform", "translateX(250px)");
$('#toolbar').css("width", "70px");
// change toolbar rotation
$("#toolbar").animate({
deg: 0
}, {
duration: speed,
queue: false,
step: function(now) {
$(this).css({
transform: "rotate(" + now + "deg)"
})
}
})
} else {
$('#toolbar').css("transform", "translateX(250px)");
$('#toolbar').css("width", "75px");
// change toolbar rotation
$("#toolbar").animate({
deg: 90
}, {
duration: speed,
queue: false,
step: function(now) {
$(this).css({
transform: "rotate(" + now + "deg)"
})
}
})
}
});
#toolbar {
width:70px;
height:70px;
transition: transform 500ms linear;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<img id="toolbar" alt="toolbar" src="http://pngimg.com/uploads/cursor/cursor_PNG67.png">