Disable Firefox going back and forth in history when overscrolling horizontally

cross-posted from: https://lemmy.world/post/332512

Whenever I accidentally scroll too far left or right in Firefox, it goes back or forth in my history, which is very annoying. How could I disable this?