Nonadiabatic quantum phase transition in a trapped spinor condensate