Learn Create Your Own Split Screen

Next Page

Here's the plan for how we'll move the viewport.

When the hero moves across the canvas, we just let it move normally.

But once it gets within a certain distance of the edge, instead of moving the hero, we move the viewport.

Because we move the hero, but also move the viewport, the hero stays at a fixed position relative to the edge of the viewport, and all the background appears to scroll past.