Remove workaround for TransformOperationsTransition
This commit is contained in:
Родитель
1bc6e06e65
Коммит
6d818d3249
|
@ -108,16 +108,16 @@
|
|||
HorizontalScrollBarVisibility="Auto">
|
||||
<paz:ZoomBorder Name="ZoomBorder1"
|
||||
Stretch="None"
|
||||
ZoomSpeed="1.2"
|
||||
ZoomSpeed="1.5"
|
||||
EnableConstrains="False"
|
||||
Background="SlateBlue" ClipToBounds="True" Focusable="True"
|
||||
VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
|
||||
<Border Background="Gray" BorderBrush="Yellow" BorderThickness="10">
|
||||
<!-- <Border.Transitions> -->
|
||||
<!-- <Transitions> -->
|
||||
<!-- <paz:TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.2" /> -->
|
||||
<!-- </Transitions> -->
|
||||
<!-- </Border.Transitions> -->
|
||||
<Border.Transitions>
|
||||
<Transitions>
|
||||
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.1" />
|
||||
</Transitions>
|
||||
</Border.Transitions>
|
||||
<Canvas Background="LightGray" Width="300" Height="300">
|
||||
<Rectangle Canvas.Left="125" Canvas.Top="125" Width="50" Height="50" Fill="Red" />
|
||||
<StackPanel Canvas.Left="100" Canvas.Top="200">
|
||||
|
@ -149,16 +149,16 @@
|
|||
HorizontalScrollBarVisibility="Auto">
|
||||
<paz:ZoomBorder Name="ZoomBorder2"
|
||||
Stretch="None"
|
||||
ZoomSpeed="1.2"
|
||||
ZoomSpeed="1.5"
|
||||
EnableConstrains="False"
|
||||
Background="SlateBlue" ClipToBounds="True" Focusable="True"
|
||||
VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
|
||||
<Canvas Width="300" Height="300">
|
||||
<!-- <Canvas.Transitions> -->
|
||||
<!-- <Transitions> -->
|
||||
<!-- <paz:TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.2" /> -->
|
||||
<!-- </Transitions> -->
|
||||
<!-- </Canvas.Transitions> -->
|
||||
<Canvas.Transitions>
|
||||
<Transitions>
|
||||
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.1" />
|
||||
</Transitions>
|
||||
</Canvas.Transitions>
|
||||
<Rectangle Fill="Red" Width="100" Height="100" Canvas.Left="0" Canvas.Top="0" />
|
||||
<Rectangle Fill="Green" Width="100" Height="100" Canvas.Left="100" Canvas.Top="0" />
|
||||
<Rectangle Fill="Blue" Width="100" Height="100" Canvas.Left="200" Canvas.Top="0" />
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Transformation;
|
||||
|
||||
namespace Avalonia.Controls.PanAndZoom
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines how a TransformOperations property should be animated.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Workaround for https://github.com/AvaloniaUI/Avalonia/issues/6494
|
||||
/// </remarks>
|
||||
public class TransformOperationsTransition : Transition<ITransform>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override IObservable<ITransform> DoTransition(IObservable<double> progress, ITransform oldValue, ITransform newValue)
|
||||
{
|
||||
return progress.Select(p =>
|
||||
{
|
||||
var f = Easing.Ease(p);
|
||||
var builder = new TransformOperations.Builder(1);
|
||||
var matrix1 = (oldValue as TransformOperations)?.Value ?? Matrix.Identity;
|
||||
var matrix2 = (newValue as TransformOperations)?.Value ?? Matrix.Identity;
|
||||
var result = new Matrix(
|
||||
matrix1.M11 + (matrix2.M11 - matrix1.M11) * f,
|
||||
matrix1.M12 + (matrix2.M12 - matrix1.M12) * f,
|
||||
matrix1.M21 + (matrix2.M21 - matrix1.M21) * f,
|
||||
matrix1.M22 + (matrix2.M22 - matrix1.M22) * f,
|
||||
matrix1.M31 + (matrix2.M31 - matrix1.M31) * f,
|
||||
matrix1.M32 + (matrix2.M32 - matrix1.M32) * f);
|
||||
|
||||
builder.AppendMatrix(result);
|
||||
|
||||
return builder.Build();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче