There are plenty of YouTube videos that explain this; how to do it and how it works.
Basically, following the video:
- Choose the spell that has the animation you want to use, and put it on your main hand (primary left and right hand selection in the inventory screen)
- Set the spell that you want to actually cast, to a hotkey that you will use.
- You want to go to your off-hand (secondary left and right hand in the inventory screen), and choose one spell that you can switch from. Some spells will not allow you to weapon swap (weapon you hit w) when you're holding down the right click button. It can even be a normal weapon attack.
- At the exact same time, weapon swap to your main hand (that you have the spell you will use the animation of), and press the hotkey of the spell you want to cast.