Zooming out canvas does not keep position

These three lines can move out of the ``if (direction ...)`` blocks.