fix gallery animation glitch