Whether the character is moved in the animation or code depends on your game, there is no “better” way.
The question is as simple as do you want your character to actually move vertically for interaction purposes when he attacks or is it just aesthetics for the attack to look good?