Prevent the preview from going out of image bounds