[NUI] Modify NUI Seamless animation bug (#2334)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Seamless.Xaml / NUIBrokerSample / SeamlessAnimation / ObjectAnimationManager.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using Tizen.NUI;
5
6 namespace NUIBrokerSample
7 {
8     class ObjectAnimationManager
9     {
10         private XamlPage xamlPage;
11         private Position defaultPosition = new Position(0, 0);
12
13         public ObjectAnimationManager(XamlPage xamlPage)
14         {
15             this.xamlPage = xamlPage;
16         }
17         
18         public void StartIconAnimationByDirection(bool direction)
19         {
20             if(direction)
21             {
22                 xamlPage.mainView.Hide();
23                 xamlPage.picture.Hide();
24                 defaultPosition = xamlPage.mainViewModel.MainPosition;
25
26                 Animation ani = new Animation(500);
27                 ani.DefaultAlphaFunction = GetSineInOut80();
28                 ani.AnimateTo(xamlPage.IconView, "Position", new Position(0, 150));
29                 ani.AnimateTo(xamlPage.AddView, "Position", new Position(30, 180));
30
31                 ani.AnimateTo(xamlPage.IconView, "Scale", new Vector3(1.3f, 1.3f, 1.3f));
32                 ani.AnimateTo(xamlPage.AddView, "Scale", new Vector3(0.5f, 0.5f, 0.5f));
33
34                 ani.AnimateTo(xamlPage.MainProfileText, "Position", new Position(0, 220));
35
36                 ani.AnimateTo(xamlPage.AnimationView, "Size", new Size(Window.Instance.WindowSize));
37                 ani.AnimateTo(xamlPage.AnimationView, "Position", new Position(0, 0));
38
39                 ani.AnimateTo(xamlPage.cinematicText, "Position", new Position(0, 320));
40
41                 ani.Play();
42
43             }
44             else
45             {
46                 int startTime = 200;
47                 int endTime = 400;
48                 xamlPage.mainView.Show();
49                 xamlPage.picture.Show();
50
51                 Animation ani = new Animation(endTime);
52                 ani.DefaultAlphaFunction = GetSineInOut80();
53                 ani.AnimateTo(xamlPage.IconView, "Position", new Position(-160, 80), startTime, endTime);
54                 ani.AnimateTo(xamlPage.AddView, "Position", new Position(160, 80), startTime, endTime);
55
56                 ani.AnimateTo(xamlPage.IconView, "Scale", new Vector3(1.0f, 1.0f, 1.0f), startTime, endTime);
57                 ani.AnimateTo(xamlPage.AddView, "Scale", new Vector3(1.0f, 1.0f, 1.0f), startTime, endTime);
58
59                 ani.AnimateTo(xamlPage.MainProfileText, "Position", new Position(0, 60), startTime, endTime);
60
61                 ani.AnimateTo(xamlPage.AnimationView, "Size", new Size(470, 600), startTime, endTime);
62                 ani.AnimateTo(xamlPage.AnimationView, "Position", defaultPosition);
63
64                 ani.AnimateTo(xamlPage.cinematicText, "Position", new Position(0, 150));
65
66                 ani.Play();
67
68             }
69         }
70
71
72         private AlphaFunction GetSineInOut80()
73         {
74             return new AlphaFunction(new Vector2(0.45f, 0.43f), new Vector2(0.41f, 1.0f));
75         }
76     }
77 }