I was wondering if this is the right way of how the threefold repetition works. Thanks. (The image is in gif format, it should play automatically.)
The confusion regarding the right to claim a draw when the position occurs 3 times results from the common misnomer for the situation: "Three-Fold Repetition". A correct term could be Three-Fold Occurrence.
As a result, in your diagram, after there have been 2 repetitions (which shows in the animation as "Repitition (sic) 2", there have been 3 occurrences of the position, and a draw may be claimed. The game is not actually "drawn" until a claim is made and the Arbiter or Tournament Director approves the claim. This also has the result that if the player creating the 3rd occurrence of the position neglects to make the claim and proceeds to make a move, the right to claim a draw for this situation expires instantly, with his move.
Note that the protocol for making such a claim must be (to avoid causing his right to claim to expire) the following: The player announces his intention to make the move and cause the 3-fold occurrence, makes the claim to the TD before moving, and the claim is adjudicated. The rules do not describe whether the TD will require the player to make the move, but it would seem that he must, for the claim to be completed, or he will not have fulfilled his claim by causing the position to appear. If it is determined (after the move has been made, presumably) that the position is not in fact a third occurrence, presumably his move must stand, and a penalty for incorrect claim would be levied.
Note that all of the legal moves in all of the 3 occurrences must be identical, including rights to castle as well as any possibility of en passant capture. It is not sufficient that the same pieces merely appear on the same squares.