Bed with two folds that have independent onclicks, with a test to check position of the first.
the move is tied to the second fold.

It may be enough or give you some ideas

You could consider a Set function for conditions, required if are placing the animate in the parent

folding example.skp