Learn Create Your Own Split Screen

Next Page

You're probably thinking handling touch will be equally easy: we just add a listener for swipe events, and do the appropriate thing.

The only problem is, Javascript does not know anything about swipes. It knows about touches starting, moving and ending. So we have to make our own.


When you think about it, a swipe is a touch that starts in one place, moves in a direction, and ends in another place.

We can do this without too much sweat.

The idea will be that you swipe anywhere on the screen, it doesn't have to be on the ball.