A fix for animations with frame_direction = -1 getting stuck on the first frame.

Also includes a test to verify the fix.