I'd also recommend double checking to make sure you are not overriding animations when you are not meaning to.
For example, in your code you are always playing idle if there is no horizontal movement. If the player is in the air, this can cause the issue where the animation changes to idle, and then in a later condition changes to jumping, but because its already changed to idle, it resets the jump animation. To fix this, I'd check to make sure the player is on the ground before changing to the idle animation.