diff --git a/QuestPDF.Previewer/InteractiveCanvas.cs b/QuestPDF.Previewer/InteractiveCanvas.cs
index 0494878..2c808ac 100644
--- a/QuestPDF.Previewer/InteractiveCanvas.cs
+++ b/QuestPDF.Previewer/InteractiveCanvas.cs
@@ -23,12 +23,14 @@ class InteractiveCanvas : ICustomDrawOperation
private const float MaxScale = 10f;
private const float PageSpacing = 25f;
- private const float SafeZone = 50f;
+ private const float SafeZone = InnerGradientSize;
- public float TotalHeight => Pages.Sum(x => x.Size.Height) + (Pages.Count - 1) * PageSpacing;
+ public float TotalPagesHeight => Pages.Sum(x => x.Size.Height) + (Pages.Count - 1) * PageSpacing;
+ public float TotalHeight => TotalPagesHeight + SafeZone * 2 / Scale;
public float MaxWidth => Pages.Any() ? Pages.Max(x => x.Size.Width) : 0;
+
public float MaxTranslateY => -(Height / 2 - SafeZone) / Scale;
- public float MinTranslateY => (Height / 2 - SafeZone) / Scale - TotalHeight;
+ public float MinTranslateY => (Height / 2 + SafeZone) / Scale - TotalHeight;
public float ScrollPercentY
{
@@ -46,10 +48,8 @@ class InteractiveCanvas : ICustomDrawOperation
{
get
{
- if (TotalHeight * Scale < Height)
- return 1;
-
- return Math.Clamp(Height / Scale / (MaxTranslateY - MinTranslateY), 0, 1);
+ var viewPortSize = Height / Scale / TotalHeight;
+ return Math.Clamp(viewPortSize, 0, 1);
}
}
@@ -63,14 +63,14 @@ class InteractiveCanvas : ICustomDrawOperation
private void LimitTranslate()
{
- if (TotalHeight * Scale > Height)
+ if (TotalPagesHeight * Scale > Height)
{
TranslateY = Math.Min(TranslateY, MaxTranslateY);
TranslateY = Math.Max(TranslateY, MinTranslateY);
}
else
{
- TranslateY = -TotalHeight / 2;
+ TranslateY = -TotalPagesHeight / 2;
}
if (Width / Scale < MaxWidth)
@@ -178,15 +178,15 @@ class InteractiveCanvas : ICustomDrawOperation
#region inner viewport gradient
- private const float InnerGradientSize = 24f;
+ private const int InnerGradientSize = 24;
private static readonly SKColor InnerGradientColor = SKColor.Parse("#666");
private void DrawInnerGradient(SKCanvas canvas)
{
// gamma correction
var colors = Enumerable
- .Range(0, 17)
- .Select(x => 1f - x / 16f)
+ .Range(0, InnerGradientSize)
+ .Select(x => 1f - x / (float) InnerGradientSize)
.Select(x => Math.Pow(x, 2f))
.Select(x => (byte)(x * 255))
.Select(x => InnerGradientColor.WithAlpha(x))
diff --git a/QuestPDF.Previewer/PreviewerWindow.axaml b/QuestPDF.Previewer/PreviewerWindow.axaml
index 34a2a14..50daf0e 100644
--- a/QuestPDF.Previewer/PreviewerWindow.axaml
+++ b/QuestPDF.Previewer/PreviewerWindow.axaml
@@ -26,9 +26,9 @@
-
+ TextAlignment="Center" Text="QuestPDF Previewer" FontSize="14" Foreground="#DFFF" FontWeight="Regular" IsHitTestVisible="False" />
-
-
-
diff --git a/QuestPDF.Previewer/PreviewerWindow.axaml.cs b/QuestPDF.Previewer/PreviewerWindow.axaml.cs
index 5651a2e..0813933 100644
--- a/QuestPDF.Previewer/PreviewerWindow.axaml.cs
+++ b/QuestPDF.Previewer/PreviewerWindow.axaml.cs
@@ -24,8 +24,7 @@ namespace QuestPDF.Previewer
set => SetValue(DocumentProperty, value);
}
- public static readonly StyledProperty CurrentScrollProperty =
- AvaloniaProperty.Register(nameof(CurrentScroll));
+ public static readonly StyledProperty CurrentScrollProperty = AvaloniaProperty.Register(nameof(CurrentScroll));
public float CurrentScroll
{
@@ -33,8 +32,7 @@ namespace QuestPDF.Previewer
set => SetValue(CurrentScrollProperty, value);
}
- public static readonly StyledProperty ScrollViewportSizeProperty =
- AvaloniaProperty.Register(nameof(ScrollViewportSize));
+ public static readonly StyledProperty ScrollViewportSizeProperty = AvaloniaProperty.Register(nameof(ScrollViewportSize));
public float ScrollViewportSize
{
@@ -42,8 +40,7 @@ namespace QuestPDF.Previewer
set => SetValue(ScrollViewportSizeProperty, value);
}
- public static readonly StyledProperty VerticalScrollbarVisibleProperty =
- AvaloniaProperty.Register(nameof(VerticalScrollbarVisible));
+ public static readonly StyledProperty VerticalScrollbarVisibleProperty = AvaloniaProperty.Register(nameof(VerticalScrollbarVisible));
public bool VerticalScrollbarVisible
{
@@ -59,9 +56,8 @@ namespace QuestPDF.Previewer
.Subscribe(e => Dispatcher.UIThread.Post(() =>
{
VerticalScrollbarVisible = e.NewValue.Value < 1;
- Debug.WriteLine($"Scrollbar visible: {VerticalScrollbarVisible}");
}));
-
+
// this.FindControl