feat: respect presenter size change.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Threading;
|
||||
using Irihi.Avalonia.Shared.Helpers;
|
||||
@@ -75,6 +76,10 @@ public class Marquee : ContentControl
|
||||
_timer.Elapsed -= TimerOnTick;
|
||||
_timer.Stop();
|
||||
_timer.Dispose();
|
||||
if (Presenter is not null)
|
||||
{
|
||||
Presenter.SizeChanged -= OnPresenterSizeChanged;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -104,6 +109,22 @@ public class Marquee : ContentControl
|
||||
set => SetValue(SpeedProperty, value);
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
{
|
||||
base.OnApplyTemplate(e);
|
||||
if (Presenter is not null)
|
||||
{
|
||||
Presenter.SizeChanged+= OnPresenterSizeChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPresenterSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
InvalidatePresenterPosition();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void TimerOnTick(object sender, System.EventArgs e)
|
||||
{
|
||||
var layoutValues = Dispatcher.UIThread.Invoke(GetLayoutValues);
|
||||
|
||||
Reference in New Issue
Block a user