If you change to another gamemode while inside the view of a mob in spectator mode, your hand moves up and down and you can move it across the screen but you still look and move in the direction of the mob. If you press shift while this is happening, it puts you into the mode you were trying to get into.
Related issues
is duplicated by
relates to
Comments

Attacking mobs while doing this causes you to be kicked with: http://puu.sh/6DPXs
A Mo you are describing MC-46411
Same issue for me, When you move your mouse the block in your hand will move weirdly.
Confirmed, also noticed that when viewing through the eyes of a creeper, whatever direction you were facing when you started spectating (North, South, etc) You will be locked in that view, even if the creeper moves his head.
Things related to do this: If you are spectating a mob, and the game teleports you, you will not be teleported
If you are switched gamemodes while spectating a mob/player, If you shift to disconnect from the mob, it will allow you to hit the players around you, but you will still be invisible.
Confirmed