Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A animation helper that morphs between two controls #4338

Closed
wants to merge 99 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
9a4c2d3
Add TransitionHelper for morphs between two controls.
HHChaos Oct 22, 2021
b890cad
Add sample for TransitionHelper.
HHChaos Oct 22, 2021
da04e1d
Fix format
HHChaos Oct 22, 2021
c6292e6
Fix sample format
HHChaos Oct 25, 2021
0bd22c1
Add unpaired elements animation
HHChaos Oct 25, 2021
6e405a1
Update animated elements when setting AnimationConfigs
HHChaos Oct 25, 2021
40c7af6
Fix scale animation.
HHChaos Oct 25, 2021
ebb0ed2
Update TransitionHelperXaml.bind
HHChaos Oct 25, 2021
b32eef2
update method names
HHChaos Oct 25, 2021
4998602
Update sample
HHChaos Oct 25, 2021
22f6779
Remove redundant code
HHChaos Oct 25, 2021
27d5667
Modify sample layout
HHChaos Oct 26, 2021
51bb56c
Fix dark mode
HHChaos Oct 27, 2021
863b64a
Add ScaleMode
HHChaos Nov 10, 2021
25ed52f
Added StartTransitionAction
HHChaos Nov 10, 2021
637800a
Add ReverseTransitionAction
HHChaos Nov 11, 2021
850fc53
Update sample
HHChaos Nov 11, 2021
c7f1c34
Add ContentProperty for TransitionHelper.
HHChaos Nov 15, 2021
1089a86
Merge branch 'main' into hhchaos/transitionHelper
HHChaos Jan 21, 2022
c2b3d7e
resolve comments
HHChaos Jan 21, 2022
e3fb383
Fix build error
HHChaos Jan 21, 2022
03700be
Modify VisualStateToggleMethod logic
HHChaos Feb 9, 2022
b3aa3c1
update some method name
HHChaos Feb 10, 2022
cfecd96
Add a new sample for StartTransitionAction/ReverseTransitionAction
HHChaos Feb 10, 2022
fb661cf
Add Reset
HHChaos Mar 20, 2022
6d77c8f
update method name
HHChaos Mar 20, 2022
e6ab543
format
HHChaos Mar 20, 2022
afc2314
Add OpacityAnimationMode
HHChaos Mar 21, 2022
e90a16c
Fix default value
HHChaos Mar 21, 2022
8826477
update the logic of setter
HHChaos Mar 22, 2022
bedbbfc
Fix reset bug
HHChaos Mar 23, 2022
300a10e
update RestoreUIElements
HHChaos Apr 14, 2022
2d4d589
Add IsHitTestVisibleWhenAnimating
HHChaos Apr 14, 2022
b306454
Add DefaultAnimationConfig and update logic
HHChaos Apr 14, 2022
034298e
Add NormalizedCenterPoint for AnimationConfig
HHChaos Apr 14, 2022
bb0c7b8
Add EasingType and EasingMode for AnimationConfig
HHChaos Apr 15, 2022
e5ed620
Change Vector2/Vector3 to Point for xaml
HHChaos Apr 15, 2022
7dde461
remove useless using
HHChaos Apr 15, 2022
4852783
Update
HHChaos Apr 15, 2022
487e0a2
Fix a bug
HHChaos Apr 15, 2022
ab8fc7c
update transition strategy.
HHChaos May 23, 2022
7b9fe59
format some code
HHChaos May 24, 2022
a0e779d
update
HHChaos May 24, 2022
6e2712b
Update code file structure
HHChaos May 25, 2022
1fd61cf
Remove TransitionMode
HHChaos Jun 28, 2022
1e1347a
Update some function names
HHChaos Jun 28, 2022
05cb808
update independent elements animation
HHChaos Jul 10, 2022
3d3d2fa
Add clip animation
Jul 13, 2022
8e8f54b
update
Jul 13, 2022
da5b103
Fix clip animations
Jul 14, 2022
acd6ac3
fix clip animation
Jul 15, 2022
a2c4116
Add KeyFrameAnimationGroupController
Jul 21, 2022
2d0dcf2
Update TransitionHelper.Animation.cs
HHChaos Jul 21, 2022
db7fd0b
update KeyFrameAnimationGroupController
Jul 22, 2022
3e0c18c
Merge branch 'hhchaos/transitionHelper' of https://github.com/HHChaos…
Jul 22, 2022
511b7a8
update animations
Jul 22, 2022
953fb99
update default EasingType
Jul 22, 2022
62feb06
add IndependentTranslation
Jul 22, 2022
8aca551
remove useless code
Jul 22, 2022
744f339
Fix null
Jul 22, 2022
2adde3b
update Opacity animation
Jul 22, 2022
b734dce
Fix independent animation
Jul 25, 2022
f265ad5
update
Jul 25, 2022
ef1add7
update
Jul 25, 2022
e4fa6c6
Add InverseEasingFunctionWhenReversing
Jul 27, 2022
2d07f75
fix inverse easing
HHChaos Jul 27, 2022
3489545
Fix inverse easing
Jul 28, 2022
b25d7fb
merge remote
Jul 28, 2022
932145d
update
Jul 28, 2022
530212d
update TransitionHelper
Jul 29, 2022
62cee85
Add OpacityTransitionProgressKey
Aug 1, 2022
7564784
Added coordinated animation
Aug 23, 2022
7f24187
fix format
Aug 23, 2022
0b9201d
change some name
Aug 23, 2022
a5f16e4
update
Aug 23, 2022
13d84a0
Merge branch 'main' into hhchaos/transitionHelper
HHChaos Sep 28, 2022
38cf490
update
Sep 28, 2022
2b21985
add FindDescendantsWithBFSAndPruneAndPredicate
Sep 29, 2022
f7c469d
update
Sep 29, 2022
5dc80ac
Use Queue instead of List
Sep 30, 2022
bed1103
Add AnimatedElements
Sep 30, 2022
c66fc77
update
Sep 30, 2022
d8ce6b1
Add CustomScaleHandler to TransitionConfig
Sep 30, 2022
c5822bd
update
Sep 30, 2022
c84b10c
update
Sep 30, 2022
1cdf56e
update
Sep 30, 2022
9e50006
update clip logic
Oct 8, 2022
9e51142
nullable enable & add IEasingFunctionFactory
Oct 9, 2022
688490c
remove some useless code
Oct 9, 2022
0d25167
add sample for CustomScalingCalculator
Oct 10, 2022
888567a
update
Oct 10, 2022
6144f05
update xml doc
Oct 10, 2022
d90482e
update xml doc
Oct 10, 2022
ca87ce4
update xml doc
Oct 10, 2022
6c34375
fix format
Oct 11, 2022
7245354
fix build error
Nov 7, 2022
9ef2190
Merge branch 'main' into hhchaos/transitionHelper
HHChaos Nov 7, 2022
7ea2eb8
update AnimateOpacity logic
Nov 7, 2022
e8ce4dd
update
Nov 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@
<Compile Include="SamplePages\TokenizingTextBox\TokenizingTextBoxPage.xaml.cs">
<DependentUpon>TokenizingTextBoxPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\TransitionHelper\CustomTextScalingCalculator.cs" />
<Compile Include="SamplePages\TransitionHelper\TransitionHelperPage.xaml.cs">
<DependentUpon>TransitionHelperPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\Triggers\FullScreenModeStateTriggerPage.xaml.cs">
<DependentUpon>FullScreenModeStateTriggerPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -647,6 +651,9 @@
<Content Include="SamplePages\Animations\Shadows\AnimatedCardShadowXaml.bind" />
<Content Include="SamplePages\KeyDownTriggerBehavior\KeyDownTriggerBehaviorXaml.bind" />
<Content Include="SamplePages\RichSuggestBox\RichSuggestBoxCode.bind" />
<Content Include="SamplePages\TransitionHelper\TransitionHelperCode.bind" />
<Content Include="SamplePages\TransitionHelper\TransitionHelperXaml.bind" />
<Content Include="SamplePages\Animations\Actions\StartTransitionActionXaml.bind" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
Expand Down Expand Up @@ -1111,6 +1118,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Content>
<Page Include="SamplePages\TransitionHelper\TransitionHelperPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\Triggers\FullScreenModeStateTriggerPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -1500,7 +1511,11 @@
<Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>
</SDKReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Reference Include="System.Numerics">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Numerics.dll</HintPath>
</Reference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ani="using:Microsoft.Toolkit.Uwp.UI.Animations"
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<ani:TransitionHelper x:Key="MyTransitionHelper">
<ani:TransitionConfig Id="icon"
ScaleMode="Scale" />
<ani:TransitionConfig Id="name"
ScaleMode="ScaleY" />
</ani:TransitionHelper>
</Page.Resources>
<StackPanel Margin="50,20"
Spacing="20">
<StackPanel Orientation="Horizontal"
Spacing="16">
<Button Content="Start Transition">
<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Click">
<behaviors:StartTransitionAction Source="{Binding ElementName=FirstControl}"
Target="{Binding ElementName=SecondControl}"
Transition="{StaticResource MyTransitionHelper}" />
</interactions:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Button>
<Button Content="Reverse Transition">
<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Click">
<behaviors:ReverseTransitionAction Transition="{StaticResource MyTransitionHelper}" />
</interactions:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Button>
</StackPanel>
<Grid>
<Grid x:Name="FirstControl"
VerticalAlignment="Top">
<StackPanel Orientation="Horizontal"
Spacing="10">
<Border Width="50"
Height="50"
Padding="8"
ani:TransitionHelper.Id="icon"
Background="Gray"
CornerRadius="25">
<Image Source="ms-appx:///Assets/ToolkitLogo.png" />
</Border>
<TextBlock VerticalAlignment="Center"
ani:TransitionHelper.Id="name">
Windows Community Toolkit
</TextBlock>
</StackPanel>
</Grid>
<Grid x:Name="SecondControl"
MaxWidth="400"
VerticalAlignment="Top"
Visibility="Collapsed">
<StackPanel Spacing="20">
<Border Width="80"
Height="80"
Padding="8"
ani:TransitionHelper.Id="icon"
Background="Gray"
CornerRadius="8">
<Image Source="ms-appx:///Assets/ToolkitLogo.png" />
</Border>
<TextBlock ani:TransitionHelper.Id="name"
FontSize="24"
FontWeight="SemiBold">
Windows Community Toolkit
</TextBlock>
<TextBlock ani:TransitionHelper.CoordinatedTarget="name"
TextWrapping="Wrap">
The Windows Community Toolkit is a collection of helper functions, custom controls, and app services. It simplifies and demonstrates common developer patterns when building experiences for Windows.
</TextBlock>
</StackPanel>
</Grid>
</Grid>
</StackPanel>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Numerics;
using Microsoft.Toolkit.Uwp.UI;
using Microsoft.Toolkit.Uwp.UI.Animations.Helpers;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
public sealed class CustomTextScalingCalculator : IScalingCalculator
{
/// <inheritdoc/>
public Vector2 GetScaling(UIElement source, UIElement target)
{
var sourceTextElement = source?.FindDescendantOrSelf<TextBlock>();
var targetTextElement = target?.FindDescendantOrSelf<TextBlock>();
if (sourceTextElement is not null && targetTextElement is not null)
{
var scale = targetTextElement.FontSize / sourceTextElement.FontSize;
return new Vector2((float)scale);
}

return new Vector2(1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Create a TransitionHelper.
var transitionHelper = new TransitionHelper();

// Configure the elements that need to be connected by animation, if the elements use the default configuration, they do not need to be listed here.
transitionHelper.Configs = new List<TransitionConfig>
{
new()
{
Id = "background",
ScaleMode = ScaleMode.Scale
},
new()
{
Id = "image",
ScaleMode = ScaleMode.Scale
},
new()
{
Id = "name",
ScaleMode = ScaleMode.ScaleY
},
new()
{
Id = "desc",
EnableClipAnimation = true
},
};
transitionHelper.Source = FirstControl;
transitionHelper.Target = SecondControl;

// Animate.
await transitionHelper.AnimateAsync();

// Reverse.
await transitionHelper.ReverseAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.TransitionHelperPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ani="using:Microsoft.Toolkit.Uwp.UI.Animations"
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.SamplePages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<local:CustomTextScalingCalculator x:Key="test" />
</Page.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Padding="50,20">
<TextBlock Text="Click the arrow button to view the animation." />
<!--
The use of animations:TransitionHelper.Id and StartTransitionAction/ReverseTransitionAction here is meaningless,
but it seems that if you do not declare it in advance,
the sample app will not be able to recognize them
-->
<Button ani:TransitionHelper.Id="test"
Visibility="Collapsed">
<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Click">
<behaviors:StartTransitionAction />
<behaviors:ReverseTransitionAction />
</interactions:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Button>
</Grid>
<Grid x:Name="XamlRoot"
Grid.Row="1" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Windows.UI.Xaml;

namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
public sealed partial class TransitionHelperPage : IXamlRenderListener
{
public TransitionHelperPage()
{
InitializeComponent();
}

public void OnXamlRendered(FrameworkElement control)
{
}
}
}
Loading