gluonhq / maps

https://gluonhq.com/labs/maps/
GNU General Public License v3.0
140 stars 36 forks source link

Cannot zoom in on the map due to event with deltaY = 0.0 #36

Closed EnkeyMC closed 4 years ago

EnkeyMC commented 4 years ago

Some mouse wheels are producing event with delta Y = 0.0 right before the actual scroll event which due to the line below causes the map to zoom out on this event. This means you cannot zoom in on the map because it also zooms out right before the zoom in. It also zooms out twice on zoom out.

https://github.com/gluonhq/maps/blob/60db8e95609cb7002a710ec06282cdac3cf12db5/maps/src/main/java/com/gluonhq/maps/MapView.java#L112

A workaround is to filter out those event in subclass of MapView:

public class CustomMapView extends MapView {
    public CustomMapView() {
        super();
        EventHandler<? super ScrollEvent> oldOnScroll = getOnScroll();
        setOnScroll(event -> {
            if (event.getDeltaY() != 0.0)
                oldOnScroll.handle(event);
        });
    }
}
abhinayagarwal commented 4 years ago

Fixed with PR #37