Fixed MouseWheel handling

This commit is contained in:
ClemensF 2021-01-07 19:27:25 +01:00
parent 8e50ad9d8f
commit 1ab76446ba
2 changed files with 6 additions and 4 deletions

View file

@ -2,6 +2,7 @@
// © 2020 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
@ -44,9 +45,9 @@ namespace MapControl
private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(this);
var zoomDelta = MouseWheelZoomDelta * point.Properties.MouseWheelDelta / 120d;
var zoomLevel = TargetZoomLevel + MouseWheelZoomDelta * Math.Sign(point.Properties.MouseWheelDelta);
ZoomMap(point.Position, TargetZoomLevel + zoomDelta);
ZoomMap(point.Position, MouseWheelZoomDelta * Math.Round(zoomLevel / MouseWheelZoomDelta));
}
}
}

View file

@ -2,6 +2,7 @@
// © 2020 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;
using System.Windows;
using System.Windows.Input;
@ -98,9 +99,9 @@ namespace MapControl
private void OnMouseWheel(object sender, MouseWheelEventArgs e)
{
var zoomDelta = MouseWheelZoomDelta * e.Delta / 120d;
var zoomLevel = TargetZoomLevel + MouseWheelZoomDelta * Math.Sign(e.Delta);
ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomDelta);
ZoomMap(e.GetPosition(this), MouseWheelZoomDelta * Math.Round(zoomLevel / MouseWheelZoomDelta));
}
}
}