Link to my blender file.https://drive.google.com/open?id=1WApKxEItBW1lrh2O9S3e7V1lGQ0xU3el
The cube snaps back to its original postion halfway through animation. I am using transformation constraint to move the cube up and down according to the rotation of cylinder.