Bläddra i källkod

Update ZoomPreviewer and ZoomPanControl behavior

- Prevent `RestartHideTimer` execution when opacity is `0` in `ZoomPreviewer`.
- Ensure `UpdatePreviewWindow` is called consistently after transform changes in `ZoomPanControl`.
Ruben 2 månader sedan
förälder
incheckning
973ce00fc4

+ 9 - 3
src/PicView.Avalonia/CustomControls/ZoomPanControl.cs

@@ -225,6 +225,9 @@ public class ZoomPanControl : Decorator
         TranslateY = translateY;
         ConstrainTranslationToBounds();
         UpdateChildTransform();
+
+        // Update preview window after transform change
+        UpdatePreviewWindow();
     }
 
     #endregion
@@ -294,6 +297,9 @@ public class ZoomPanControl : Decorator
 
         ConstrainTranslationToBounds();
         UpdateChildTransform();
+
+        // Update preview window after transform change
+        UpdatePreviewWindow();
     }
 
     private void StopPanning(object? sender, PointerReleasedEventArgs e)
@@ -347,6 +353,9 @@ public class ZoomPanControl : Decorator
         {
             ResetZoom(animated);
         }
+
+        // Update preview window after transform change
+        UpdatePreviewWindow();
     }
 
     private void ApplyZoomAndTitle(double targetScale, Point center, bool animated)
@@ -434,9 +443,6 @@ public class ZoomPanControl : Decorator
         _scaleTransform.ScaleY = Scale;
         _translateTransform.X = TranslateX;
         _translateTransform.Y = TranslateY;
-
-        // Update preview window after transform change
-        UpdatePreviewWindow();
     }
 
     private void SetTransitions(bool isAnimated)

+ 4 - 0
src/PicView.Avalonia/Views/UC/ZoomPreviewer.axaml.cs

@@ -285,6 +285,10 @@ public partial class ZoomPreviewer : UserControl
 
     private void RestartHideTimer()
     {
+        if (Opacity is 0)
+        {
+            return;
+        }
         _hideTimer?.Dispose();
         _hideTimer = new Timer(_ =>
         {