clamp viewport to prevent potential out of ranges