Clamp horizontal scroll position into valid range.
double clampX(double x, double zoomRatio) => x.clamp(0.0, getScrollableMaxX(zoomRatio));