Skip to content

Commit

Permalink
Merge pull request #553 from Jethro-Alter/Image_Zoom
Browse files Browse the repository at this point in the history
Mouse wheel for zoom; Double click to reset zoom
  • Loading branch information
xupefei authored Oct 9, 2019
2 parents 42f109b + 1f198f1 commit 7b2b6b2
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public ImagePanel()
viewPanel.PreviewMouseWheel += ViewPanel_PreviewMouseWheel;
viewPanel.MouseLeftButtonDown += ViewPanel_MouseLeftButtonDown;
viewPanel.MouseMove += ViewPanel_MouseMove;
viewPanel.MouseDoubleClick += ViewPanel_MouseDoubleClick;

viewPanel.ManipulationInertiaStarting += ViewPanel_ManipulationInertiaStarting;
viewPanel.ManipulationStarting += ViewPanel_ManipulationStarting;
Expand Down Expand Up @@ -341,6 +342,11 @@ private void ViewPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e
_dragInitPos = temp;
}

private void ViewPanel_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DoZoomToFit();
}

private void ViewPanel_MouseMove(object sender, MouseEventArgs e)
{
if (!_dragInitPos.HasValue)
Expand All @@ -366,16 +372,6 @@ private void ViewPanel_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
e.Handled = true;

if ((Keyboard.Modifiers & ModifierKeys.Control) == 0)
{
// normal scroll
viewPanel.ScrollToVerticalOffset(viewPanel.VerticalOffset - e.Delta);

ImageScrolled?.Invoke(this, e.Delta);

return;
}

// zoom
var newZoom = ZoomFactor + ZoomFactor * e.Delta / 120 * 0.1;

Expand Down

0 comments on commit 7b2b6b2

Please sign in to comment.