Problem with rotating items and changing width/height

Hi there

I made the following function to rotate some pictures. As you can see I've started trying some funky things on it.

function rotate (item){
    item.startW = item.width
    item.startH = item.height
    item.animate({
        props: {rotation:"90"},
    });
    item.width = item.startH
    item.height = item.startW
    item.scaleX = 0.7;
    item.scaleY = 0.7;
    S.update();
}

It seems that after I rotate the item, its width and height stay the original width and height, and do not follow the item's rotation to its new width and height. The problem is I am doing some adjustments to the location of the item based on the item's width and height. When I am rotating a long item it is especially noticeable.

Do you have any advice for my problem?

A couple of things... if you are wanting to do the things you listed after the animate() once the animate() finishes then you should put them in the call parameter of the animate(). Not sure if you do or not. The other thing is that there really is no width and height - it is doing the same thing as scaleX and scaleY. So you would not need both and only the last one done will win.

I think i figured out that it was something to do with the function that deals with the relocating rather than the rotation itself. I think the new width and height aren't being saved with the item when the relocation function is being called. Not sure how to fix that.

1 Like

You mean since we talked?

the post was from before we talked! I got it working now with your help. Thank you!

1 Like