diff options
author | Jose Diez <jose.manuel.diez@gmail.com> | 2015-11-11 15:39:36 +0000 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2015-11-11 18:12:05 +0000 |
commit | c05412208dd658935ca1126691f0346a558ec425 (patch) | |
tree | 49a487f2e8b837d30e468976a4cda517233b31ee /src | |
parent | 79281774a6f1e72aa6fba99dd9b3524b3cd5a2cd (diff) | |
download | imv-c05412208dd658935ca1126691f0346a558ec425.tar.gz |
Center into image when the mouse is outside bounds
Diffstat (limited to 'src')
-rw-r--r-- | src/viewport.c | 8 |
1 files changed, 4 insertions, 4 deletions
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; |