Return to previous position on trigger (Undo move)

I have a situation where a user can drag an item along the x axis and I want to provide an undo function. Clearly I know where it started, and where it is now, but I want to move the item to the last place the user left it and I cant quite wrap my head around how to do that.

Ideally, it would be nice to have an “undo” action that would set an item back to it’s previous location, size, rotation, color etc.

Any suggestions would be welcome