Why does changing the depth of water affect the position of the cap?

When the water is filled up-to the brim the plastic cap can easily stay in the middle (roughly ) of the glass.

When the water is filled till the middle the cap will always come at rest at the corner.

It will be great if somebody can explain why does this happen and also provide me with mathematical proof behind his reasoning

• Does this answer your question? Why does a cork float to the side of a glass? Jun 17, 2020 at 4:03
• @user7777777 that is half the answer. It doesn't explain why the cap remains in the middle when the glass is full. Jun 17, 2020 at 4:04
• @JohnRennie actually it does: the top-voted answer (not the accepted one) touches this case too. Jun 22, 2020 at 16:32
• @Bhavay What kind of mathematical proof could be done? Jun 23, 2020 at 10:09
• @AlexTrounev This in regard to the first pic .What am i asking is to prove that at centre sum of net forces = 0 , Also why won't it oscillate(damped oscillations due to viscous force) if the net force is always directed towards centre and rather just stay in centre when displace from the edge. Jun 23, 2020 at 14:14