Skip to content

Commit

Permalink
libGDX mouse wheel zoom with pivot, closes opensciencemap#169
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 committed Sep 16, 2016
1 parent 8f58966 commit 7427624
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions vtm-gdx/src/org/oscim/gdx/InputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,26 +218,17 @@ public boolean touchDragged(int screenX, int screenY, int pointer) {

@Override
public boolean mouseMoved(int screenX, int screenY) {

mPosX = screenX;
mPosY = screenY;
return false;
}

@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;
}
}

0 comments on commit 7427624

Please sign in to comment.