From c05412208dd658935ca1126691f0346a558ec425 Mon Sep 17 00:00:00 2001 From: Jose Diez Date: Wed, 11 Nov 2015 15:39:36 +0000 Subject: Center into image when the mouse is outside bounds --- src/viewport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/viewport.c b/src/viewport.c index 38deabc..c3fd9e2 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -85,12 +85,12 @@ void imv_viewport_zoom(struct imv_viewport *view, const struct imv_image *img, e int scaledWidth = img->width * view->scale; int scaledHeight = img->height * view->scale; - if(x > scaledWidth) { - x = scaledWidth; + if(x > scaledWidth || x < view->x) { + x = scaledWidth / 2; } - if(y > scaledHeight) { - y = scaledHeight; + if(y > scaledHeight || view->y) { + y = scaledHeight / 2; } view->scale += amount * 0.1; -- cgit v1.2.3