Fix horizontal scroll issue when zooming

Fixes #4186.