From 74276242750ffafae74b6c9d7bf3843bbfb526b3 Mon Sep 17 00:00:00 2001 From: Emux Date: Fri, 16 Sep 2016 10:09:26 +0300 Subject: [PATCH] libGDX mouse wheel zoom with pivot, closes #169 --- vtm-gdx/src/org/oscim/gdx/InputHandler.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/vtm-gdx/src/org/oscim/gdx/InputHandler.java b/vtm-gdx/src/org/oscim/gdx/InputHandler.java index 249eac7f9..ef9802f3f 100644 --- a/vtm-gdx/src/org/oscim/gdx/InputHandler.java +++ b/vtm-gdx/src/org/oscim/gdx/InputHandler.java @@ -218,7 +218,6 @@ public boolean touchDragged(int screenX, int screenY, int pointer) { @Override public boolean mouseMoved(int screenX, int screenY) { - mPosX = screenX; mPosY = screenY; return false; @@ -226,18 +225,10 @@ public boolean mouseMoved(int screenX, int screenY) { @Override public boolean scrolled(int amount) { - - if (amount > 0) { - - mMap.animator().animateZoom(250, 0.75f, 0, 0); - } else { - float fx = mPosX - mMap.getWidth() / 2; - float fy = mPosY - mMap.getHeight() / 2; - - mMap.animator().animateZoom(250, 1.333f, fx, fy); - } + float fx = mPosX - mMap.getWidth() / 2; + float fy = mPosY - mMap.getHeight() / 2; + mMap.animator().animateZoom(250, amount > 0 ? 0.75f : 1.333f, fx, fy); mMap.updateMap(false); - return true; } }