Firefox: Unreliable Rotations

When I flip my photos, it seems like Firefox thinks my cursor is leaving them, so it starts rotating back. I can manage to get it to rotate all the way at best before it rotates back to start, but most of the time it's just sort of throwing a tantrum, not knowing which way to rotate.

My code is exactly as in the video. I noticed it on the other videos dealing with these flipping cards as well.