Only allow the scroll direction you have started scrolling (prevent diagonal scrolling)

How can I make sure the scroll works only in the direction, the user started the scrolling?
E.g. if the user starts scrolling left or right, the scroll view shouldn’t move on y-axis, when the user users moves up or down.

In other words: “How to prevent diagonal scrolling?”