-
Notifications
You must be signed in to change notification settings - Fork 1.4k
A animation helper that morphs between two controls #4338
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
9a4c2d3
Add TransitionHelper for morphs between two controls.
HHChaos b890cad
Add sample for TransitionHelper.
HHChaos da04e1d
Fix format
HHChaos c6292e6
Fix sample format
HHChaos 0bd22c1
Add unpaired elements animation
HHChaos 6e405a1
Update animated elements when setting AnimationConfigs
HHChaos 40c7af6
Fix scale animation.
HHChaos ebb0ed2
Update TransitionHelperXaml.bind
HHChaos b32eef2
update method names
HHChaos 4998602
Update sample
HHChaos 22f6779
Remove redundant code
HHChaos 27d5667
Modify sample layout
HHChaos 51bb56c
Fix dark mode
HHChaos 863b64a
Add ScaleMode
HHChaos 25ed52f
Added StartTransitionAction
HHChaos 637800a
Add ReverseTransitionAction
HHChaos 850fc53
Update sample
HHChaos c7f1c34
Add ContentProperty for TransitionHelper.
HHChaos 1089a86
Merge branch 'main' into hhchaos/transitionHelper
HHChaos c2b3d7e
resolve comments
HHChaos e3fb383
Fix build error
HHChaos 03700be
Modify VisualStateToggleMethod logic
HHChaos b3aa3c1
update some method name
HHChaos cfecd96
Add a new sample for StartTransitionAction/ReverseTransitionAction
HHChaos fb661cf
Add Reset
HHChaos 6d77c8f
update method name
HHChaos e6ab543
format
HHChaos afc2314
Add OpacityAnimationMode
HHChaos e90a16c
Fix default value
HHChaos 8826477
update the logic of setter
HHChaos bedbbfc
Fix reset bug
HHChaos 300a10e
update RestoreUIElements
HHChaos 2d4d589
Add IsHitTestVisibleWhenAnimating
HHChaos b306454
Add DefaultAnimationConfig and update logic
HHChaos 034298e
Add NormalizedCenterPoint for AnimationConfig
HHChaos bb0c7b8
Add EasingType and EasingMode for AnimationConfig
HHChaos e5ed620
Change Vector2/Vector3 to Point for xaml
HHChaos 7dde461
remove useless using
HHChaos 4852783
Update
HHChaos 487e0a2
Fix a bug
HHChaos ab8fc7c
update transition strategy.
HHChaos 7b9fe59
format some code
HHChaos a0e779d
update
HHChaos 6e2712b
Update code file structure
HHChaos 1fd61cf
Remove TransitionMode
HHChaos 1e1347a
Update some function names
HHChaos 05cb808
update independent elements animation
HHChaos 3d3d2fa
Add clip animation
8e8f54b
update
da5b103
Fix clip animations
acd6ac3
fix clip animation
a2c4116
Add KeyFrameAnimationGroupController
2d0dcf2
Update TransitionHelper.Animation.cs
HHChaos db7fd0b
update KeyFrameAnimationGroupController
3e0c18c
Merge branch 'hhchaos/transitionHelper' of https://github.com/HHChaos…
511b7a8
update animations
953fb99
update default EasingType
62feb06
add IndependentTranslation
8aca551
remove useless code
744f339
Fix null
2adde3b
update Opacity animation
b734dce
Fix independent animation
f265ad5
update
ef1add7
update
e4fa6c6
Add InverseEasingFunctionWhenReversing
2d07f75
fix inverse easing
HHChaos 3489545
Fix inverse easing
b25d7fb
merge remote
932145d
update
530212d
update TransitionHelper
62cee85
Add OpacityTransitionProgressKey
7564784
Added coordinated animation
7f24187
fix format
0b9201d
change some name
a5f16e4
update
13d84a0
Merge branch 'main' into hhchaos/transitionHelper
HHChaos 38cf490
update
2b21985
add FindDescendantsWithBFSAndPruneAndPredicate
f7c469d
update
5dc80ac
Use Queue instead of List
bed1103
Add AnimatedElements
c66fc77
update
d8ce6b1
Add CustomScaleHandler to TransitionConfig
c5822bd
update
c84b10c
update
1cdf56e
update
9e50006
update clip logic
9e51142
nullable enable & add IEasingFunctionFactory
688490c
remove some useless code
0d25167
add sample for CustomScalingCalculator
888567a
update
6144f05
update xml doc
d90482e
update xml doc
ca87ce4
update xml doc
6c34375
fix format
7245354
fix build error
9ef2190
Merge branch 'main' into hhchaos/transitionHelper
HHChaos 7ea2eb8
update AnimateOpacity logic
e8ce4dd
update
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add sample for TransitionHelper.
- Loading branch information
commit b890cad82fd1bacd7c97d91a3fc6cce31437e5ce
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.22 KB
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TransitionHelper/TransitionHelper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions
27
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TransitionHelper/TransitionHelperCode.bind
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //create a TransitionHelper. | ||
| var TransitionHelper transitionHelper = new TransitionHelper(); | ||
|
|
||
| //Configure TransitionHelper. | ||
| transitionHelper.AnimationConfigs = new AnimationConfig[]{ | ||
| new AnimationConfig | ||
| { | ||
| Id = "background" | ||
| }, | ||
| new AnimationConfig | ||
| { | ||
| Id = "image", | ||
| AdditionalAnimations = new AnimationTarget[]{ AnimationTarget.Scale } | ||
| }, | ||
| new AnimationConfig | ||
| { | ||
| Id = "guide" | ||
| }, | ||
| }; | ||
| transitionHelper.Source = FirstControl; | ||
| transitionHelper.Target = SecondControl; | ||
|
|
||
| //Animate. | ||
| await transitionHelper.AnimateAsync() | ||
|
|
||
| //Reverse. | ||
| await transitionHelper.ReverseAsync(); |
10 changes: 10 additions & 0 deletions
10
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TransitionHelper/TransitionHelperPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <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:animations="using:Microsoft.Toolkit.Uwp.UI.Animations" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| mc:Ignorable="d"> | ||
| <Grid x:Name="XamlRoot" | ||
| animations:TransitionHelper.Id="root" /> | ||
| </Page> |
144 changes: 144 additions & 0 deletions
144
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TransitionHelper/TransitionHelperPage.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| // 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; | ||
| using Windows.UI.Xaml; | ||
| using Windows.UI.Xaml.Controls; | ||
| using Windows.UI.Xaml.Input; | ||
|
|
||
| namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages | ||
| { | ||
| /// <summary> | ||
| /// A page that shows how to use the <see cref="TransitionHelper"/> helper. | ||
| /// </summary> | ||
| public sealed partial class TransitionHelperPage : Page, IXamlRenderListener | ||
| { | ||
| private readonly TransitionHelper _transitionHelper = new(); | ||
| private FrameworkElement _firstControl; | ||
| private FrameworkElement _secondControl; | ||
| private FrameworkElement _thirdControl; | ||
| private FrameworkElement _secondNameTextBlock; | ||
| private FrameworkElement _secondDescTextBlock; | ||
| private FrameworkElement _thirdNameTextBlock; | ||
| private FrameworkElement _thirdDescTextBlock; | ||
| private Button _secondButton; | ||
| private Button _secondBackButton; | ||
| private Button _thirdButton; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="TransitionHelperPage"/> class. | ||
| /// </summary> | ||
| public TransitionHelperPage() | ||
| { | ||
| this.InitializeComponent(); | ||
| } | ||
|
|
||
| public void OnXamlRendered(FrameworkElement control) | ||
| { | ||
| this._firstControl = control.FindChild("FirstControl"); | ||
| this._secondControl = control.FindChild("SecondControl"); | ||
| this._thirdControl = control.FindChild("ThirdControl"); | ||
| this._secondNameTextBlock = control.FindChild("SecondNameTextBlock"); | ||
| this._secondDescTextBlock = control.FindChild("SecondDescTextBlock"); | ||
| this._thirdNameTextBlock = control.FindChild("ThirdNameTextBlock"); | ||
| this._thirdDescTextBlock = control.FindChild("ThirdDescTextBlock"); | ||
| this._secondButton = control.FindChild("SecondButton") as Button; | ||
| this._secondBackButton = control.FindChild("SecondBackButton") as Button; | ||
| this._thirdButton = control.FindChild("ThirdButton") as Button; | ||
| this._firstControl.Tapped += FirstControl_Tapped; | ||
| this._secondBackButton.Click += SecondBackButton_Click; | ||
| this._secondButton.Click += SecondButton_Click; | ||
| this._thirdButton.Click += ThirdButton_Click; | ||
| } | ||
|
|
||
| private void FirstControl_Tapped(object sender, TappedRoutedEventArgs e) | ||
| { | ||
| _transitionHelper.AnimationConfigs = new AnimationConfig[]{ | ||
| new AnimationConfig | ||
| { | ||
| Id = "background" | ||
| }, | ||
| new AnimationConfig | ||
| { | ||
| Id = "image", | ||
| AdditionalAnimations = new AnimationTarget[]{ AnimationTarget.Scale } | ||
| }, | ||
| new AnimationConfig | ||
| { | ||
| Id = "guide" | ||
| }, | ||
| }; | ||
| _transitionHelper.Source = _firstControl; | ||
| _transitionHelper.Target = _secondControl; | ||
| _transitionHelper.IgnoredElementHideTranslation = new Vector3(20, 0, 0); | ||
| TransitionHelper.SetIsIgnored(_secondNameTextBlock, true); | ||
| TransitionHelper.SetIsIgnored(_secondDescTextBlock, true); | ||
| _ = _transitionHelper.AnimateAsync(); | ||
| } | ||
|
|
||
| private void SecondBackButton_Click(object sender, RoutedEventArgs e) | ||
| { | ||
| _ = _transitionHelper.ReverseAsync(); | ||
| } | ||
|
|
||
| private void SecondButton_Click(object sender, RoutedEventArgs e) | ||
| { | ||
| _transitionHelper.AnimationConfigs = new AnimationConfig[]{ | ||
| new AnimationConfig | ||
| { | ||
| Id = "background" | ||
| }, | ||
| new AnimationConfig | ||
| { | ||
| Id = "image", | ||
| AdditionalAnimations = new AnimationTarget[]{ AnimationTarget.Scale } | ||
| }, | ||
| new AnimationConfig | ||
| { | ||
| Id = "guide" | ||
| }, | ||
| new AnimationConfig | ||
| { | ||
| Id = "name", | ||
| }, | ||
| new AnimationConfig | ||
| { | ||
| Id = "desc", | ||
| }, | ||
| }; | ||
| _transitionHelper.Source = _secondControl; | ||
| _transitionHelper.Target = _thirdControl; | ||
| _transitionHelper.IgnoredElementHideTranslation = new Vector3(0, 20, 0); | ||
| TransitionHelper.SetIsIgnored(_secondNameTextBlock, false); | ||
| TransitionHelper.SetIsIgnored(_secondDescTextBlock, false); | ||
| _ = _transitionHelper.AnimateAsync(); | ||
| } | ||
|
|
||
| private void ThirdButton_Click(object sender, RoutedEventArgs e) | ||
| { | ||
| _transitionHelper.AnimationConfigs = new AnimationConfig[]{ | ||
| new AnimationConfig | ||
| { | ||
| Id = "background" | ||
| }, | ||
| new AnimationConfig | ||
| { | ||
| Id = "image", | ||
| AdditionalAnimations = new AnimationTarget[]{ AnimationTarget.Scale } | ||
| }, | ||
| new AnimationConfig | ||
| { | ||
| Id = "guide" | ||
| } | ||
| }; | ||
| _transitionHelper.Source = _thirdControl; | ||
| _transitionHelper.Target = _firstControl; | ||
| TransitionHelper.SetIsIgnored(_thirdNameTextBlock, true); | ||
| TransitionHelper.SetIsIgnored(_thirdDescTextBlock, true); | ||
| _ = _transitionHelper.AnimateAsync(); | ||
| } | ||
| } | ||
| } |
172 changes: 172 additions & 0 deletions
172
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TransitionHelper/TransitionHelperXaml.bind
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| <Page | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:ui="using:Microsoft.Toolkit.Uwp.UI" | ||
| xmlns:animations="using:Microsoft.Toolkit.Uwp.UI.Animations" | ||
| xmlns:media="using:Microsoft.Toolkit.Uwp.UI.Media" | ||
| mc:Ignorable="d"> | ||
| <Grid> | ||
| <StackPanel | ||
| x:Name="FirstControl" | ||
| Margin="100" | ||
| HorizontalAlignment="Left" | ||
| VerticalAlignment="Top" | ||
| Orientation="Horizontal" | ||
| Spacing="10"> | ||
| <Grid Width="50" Height="50"> | ||
| <Border | ||
| animations:TransitionHelper.Id="background" | ||
| Background="White" | ||
| CornerRadius="8"> | ||
| <ui:Effects.Shadow> | ||
| <media:AttachedCardShadow | ||
| BlurRadius="4" | ||
| CornerRadius="8" | ||
| Opacity="0.4" /> | ||
| </ui:Effects.Shadow> | ||
| </Border> | ||
| <PersonPicture | ||
| Width="40" | ||
| BorderThickness="0" | ||
| animations:TransitionHelper.Id="image" | ||
| ProfilePicture="ms-appx:///Assets/Photos/Owl.jpg" /> | ||
| </Grid> | ||
| <TextBlock VerticalAlignment="Center" animations:TransitionHelper.Id="guide"> | ||
| ⬅ Click Here | ||
| </TextBlock> | ||
| </StackPanel> | ||
| <Grid | ||
| x:Name="SecondControl" | ||
| Margin="150" | ||
| HorizontalAlignment="Center" | ||
| VerticalAlignment="Top" | ||
| Visibility="Collapsed"> | ||
| <Border | ||
| animations:TransitionHelper.Id="background" | ||
| Background="White" | ||
| CornerRadius="8"> | ||
| <ui:Effects.Shadow> | ||
| <media:AttachedCardShadow | ||
| BlurRadius="4" | ||
| CornerRadius="8" | ||
| Opacity="0.4" /> | ||
| </ui:Effects.Shadow> | ||
| </Border> | ||
| <StackPanel | ||
| Padding="20" | ||
| Orientation="Horizontal" | ||
| Spacing="20"> | ||
| <PersonPicture | ||
| Width="50" | ||
| BorderThickness="0" | ||
| animations:TransitionHelper.Id="image" | ||
| ProfilePicture="ms-appx:///Assets/Photos/Owl.jpg" /> | ||
| <StackPanel | ||
| Width="400" | ||
| VerticalAlignment="Center" | ||
| Spacing="5"> | ||
| <TextBlock x:Name="SecondNameTextBlock" animations:TransitionHelper.Id="name">Magic</TextBlock> | ||
| <TextBlock x:Name="SecondDescTextBlock" animations:TransitionHelper.Id="desc">Magic is a cute cat.</TextBlock> | ||
| </StackPanel> | ||
| <StackPanel animations:TransitionHelper.Id="guide" Spacing="2"> | ||
| <Button x:Name="SecondBackButton">go back</Button> | ||
| <Button x:Name="SecondButton">Click Here</Button> | ||
| </StackPanel> | ||
| </StackPanel> | ||
| </Grid> | ||
| <Grid | ||
| x:Name="ThirdControl" | ||
| Margin="0, 150" | ||
| HorizontalAlignment="Center" | ||
| VerticalAlignment="Center" | ||
| Visibility="Collapsed"> | ||
| <Border | ||
| animations:TransitionHelper.Id="background" | ||
| Background="White" | ||
| CornerRadius="8"> | ||
| <ui:Effects.Shadow> | ||
| <media:AttachedCardShadow | ||
| BlurRadius="4" | ||
| CornerRadius="8" | ||
| Opacity="0.4" /> | ||
| </ui:Effects.Shadow> | ||
| </Border> | ||
| <StackPanel | ||
| Padding="20" | ||
| HorizontalAlignment="Center" | ||
| BorderBrush="DimGray" | ||
| BorderThickness="0,0,0,0.5" | ||
| Spacing="20"> | ||
| <PersonPicture | ||
| Width="80" | ||
| BorderThickness="0" | ||
| HorizontalAlignment="Center" | ||
| animations:TransitionHelper.Id="image" | ||
| ProfilePicture="ms-appx:///Assets/Photos/Owl.jpg" /> | ||
| <StackPanel Spacing="5"> | ||
| <TextBlock | ||
| x:Name="ThirdNameTextBlock" | ||
| HorizontalAlignment="Center" | ||
| animations:TransitionHelper.Id="name" | ||
| FontSize="24"> | ||
| Magic | ||
| </TextBlock> | ||
| <TextBlock | ||
| x:Name="ThirdDescTextBlock" | ||
| HorizontalAlignment="Center" | ||
| animations:TransitionHelper.Id="desc"> | ||
| Magic is a cute cat, but sometimes very naughty. | ||
| </TextBlock> | ||
| </StackPanel> | ||
| <StackPanel Padding="50,100" animations:TransitionHelper.IsIgnored="True"> | ||
| <Rectangle | ||
| Width="200" | ||
| Height="20" | ||
| Margin="10" | ||
| HorizontalAlignment="Left" | ||
| Fill="Silver" | ||
| Opacity="0.6" | ||
| RadiusX="5" | ||
| RadiusY="5" /> | ||
| <Rectangle | ||
| Width="300" | ||
| Height="20" | ||
| Margin="10" | ||
| HorizontalAlignment="Left" | ||
| Fill="Silver" | ||
| Opacity="0.6" | ||
| RadiusX="5" | ||
| RadiusY="5" /> | ||
| <Rectangle | ||
| Width="200" | ||
| Height="20" | ||
| Margin="10" | ||
| HorizontalAlignment="Left" | ||
| Fill="Silver" | ||
| Opacity="0.6" | ||
| RadiusX="5" | ||
| RadiusY="5" /> | ||
| <Rectangle | ||
| Width="400" | ||
| Height="20" | ||
| Margin="10" | ||
| HorizontalAlignment="Left" | ||
| Fill="Silver" | ||
| Opacity="0.6" | ||
| RadiusX="5" | ||
| RadiusY="5" /> | ||
| </StackPanel> | ||
| </StackPanel> | ||
| <Button | ||
| x:Name="ThirdButton" | ||
| Margin="10" | ||
| HorizontalAlignment="Right" | ||
| VerticalAlignment="Top" | ||
| animations:TransitionHelper.Id="guide"> | ||
| Click Here | ||
| </Button> | ||
| </Grid> | ||
| </Grid> | ||
| </Page> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.