2 using System.Threading.Tasks;
4 using Tizen.NUI.BaseComponents;
5 using System.Collections.Generic;
8 namespace Tizen.NUI.Samples
10 enum TOUCH_ANIMATION_STATE
15 END_ANIMATION = NO_ANIMATION
18 public class FrameUpdateCallbackTest : IExample
21 private static string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
22 private static string[] BACKGROUND_IMAGE_PATH = {
23 resourcePath + "/images/FrameUpdateCallbackTest/launcher_bg_02_nor.png",
24 resourcePath + "/images/FrameUpdateCallbackTest/launcher_bg_03_nor.png",
25 resourcePath + "/images/FrameUpdateCallbackTest/launcher_bg_04_nor.png",
26 resourcePath + "/images/FrameUpdateCallbackTest/launcher_bg_05_nor.png",
27 resourcePath + "/images/FrameUpdateCallbackTest/launcher_bg_06_nor.png",
28 resourcePath + "/images/FrameUpdateCallbackTest/launcher_bg_apps_nor.png"
31 private static string[] APPS_IMAGE_PATH = {
32 resourcePath + "/images/FrameUpdateCallbackTest/launcher_ic_culinary_nor.png",
33 resourcePath + "/images/FrameUpdateCallbackTest/launcher_ic_family_nor.png",
34 resourcePath + "/images/FrameUpdateCallbackTest/launcher_ic_ent_nor.png",
35 resourcePath + "/images/FrameUpdateCallbackTest/launcher_ic_homecare_nor.png"
38 private static string[] APPS_ICON_NAME = {
45 private static string[] CONTROL_IMAGE_PATH = {
46 resourcePath + "/images/FrameUpdateCallbackTest/launcher_ic_apps_nor.png",
47 resourcePath + "/images/FrameUpdateCallbackTest/launcher_ic_settings_nor.png",
48 resourcePath + "/images/FrameUpdateCallbackTest/launcher_ic_viewinside_nor.png",
49 resourcePath + "/images/FrameUpdateCallbackTest/launcher_ic_timer_nor.png",
50 resourcePath + "/images/FrameUpdateCallbackTest/launcher_ic_internet_nor.png"
53 private static string[] CONTROL_ICON_NAME = {
61 private const int FRAME_RATE = 60;
62 private const int OBJECT_DELAY = 30;
63 private const int OBJECT_SIZE = 150;
64 private const int INITIAL_POSITION = 46;
65 private const int DEFAULT_SPACE = 9;
66 private const int DEVIDE_BAR_SIZE = 4;
68 private TextLabel text;
69 public class FrameUpdateCallback : FrameUpdateCallbackInterface
71 private int timeInterval;
73 private uint containerId;
74 private List<uint> viewId; ///< View ID in the container.
75 private List<float> viewPosition;
77 // Movement is position difference of Container from start position of this animation to current position.
78 // Time interval between each containerMovement entry is 16 milliseconds(about 60 fps)
80 // containerMovement[i] + containerStartPosition is the position of container after i*16 milliseconds from this animation started.
81 private List<float> containerMovement;
83 // latestMovement is actually current movement of container.
84 private float latestMovement;
86 // An icon of touchedViewIndex moves with container at the same time.
87 // Each icon of (touchedViewIndex -/+ i) moves as following container after i*OBJECT_DELAY milliseconds.
88 private int touchedViewIndex;
90 // If every icon between mLeftIndext and rightIndex is stopped, this frame callback can be reset.
91 // Then isResetTouchedViewPossible becomes true.
92 private bool isResetTouchedViewPossible;
93 private int leftIndex;
94 private int rightIndex;
96 // Total animation time from start to current.
97 private float totalAnimationTime;
98 // Total animation time from start to the time that last movement is added.
99 private float previousTotalAnimationTime;
101 // Start position of container in this animation.
102 private float containerStartPosition;
103 // Position of container at the time that last movement is added.
104 private float previousContainerPosition;
106 // This animation only need to save movement about (the number of view * OBJECT_DELAY) milliseconds.
107 // and this size is updated when new view is added.
108 // and, If the list of containerMovement size become larger than this size, remove unnecessary entries.
109 private int requiredMovementSize;
110 private bool needUpdateMovementSize;
113 private float velocity;
117 public FrameUpdateCallback()
119 viewId = new List<uint>();
120 containerMovement = new List<float>();
121 requiredMovementSize = 0;
122 needUpdateMovementSize = false;
123 isResetTouchedViewPossible = false;
126 public void ResetAnimationData()
128 SetLatestMovement(0.0f);
129 containerMovement.Clear();
130 totalAnimationTime = 0.0f;
131 previousTotalAnimationTime = 0.0f;
135 public void SetTimeInterval(int interval)
137 needUpdateMovementSize = true;
138 timeInterval = interval;
141 public void AddId(uint id)
144 needUpdateMovementSize = true;
147 public void SetContainerId(uint id)
152 public void SetContainerStartPosition(float position)
154 containerStartPosition = position;
157 public void SetLatestMovement(float movement)
159 latestMovement = movement;
162 public void ResetViewPosition()
164 viewPosition = Enumerable.Repeat(0.0f, viewId.Count).ToList();
167 public void SetViewPosition(int index, float position)
169 viewPosition[index] = position;
172 public void SetTouchedViewIndex(int controlIndex)
174 touchedViewIndex = controlIndex;
177 public void AddMovement(float movement)
179 containerMovement.Add(movement);
182 public void SetLeftIndex(int Index)
187 public void SetRightIndex(int Index)
192 public bool IsResetTouchedViewPossible()
194 return isResetTouchedViewPossible;
201 public bool IsDirty()
206 public float GetVelocity()
211 private void ComputeNewPositions(int totalTime)
213 // save latestMovement to avoid interference between thread.
214 float lastMovement = latestMovement;
215 bool isStillMoving = true;
216 for (int i = 0; i < viewId.Count; ++i)
218 if (i == touchedViewIndex)
223 // compute delay of view of i.
224 int totalDelay = Math.Abs(i - touchedViewIndex) * OBJECT_DELAY;
225 if (totalDelay > totalTime)
230 int actorTime = totalTime - totalDelay;
231 int movementIndex = actorTime / timeInterval;
232 float factor = (float)(actorTime - (movementIndex * timeInterval)) / (float)timeInterval;
234 if (movementIndex >= containerMovement.Count - 1)
236 // 1. delay is zero(every view moves with container at the same time)
237 // 2. after every icons are stopped and the finger is stopped to move, the movement is still not added more.
238 // than the view has lastMovement.
239 movement = lastMovement;
241 else if (movementIndex < 0)
243 // If this animation is just staarted and the view need to wait more.
249 // Get the movement of ith view by interpolating containerMovement
250 movement = factor * containerMovement[movementIndex + 1] + (1.0f - factor) * containerMovement[movementIndex];
253 // Prevent to overlap of each views.
254 float currentSpace = Math.Abs((viewPosition[i] + movement) - (viewPosition[touchedViewIndex] + lastMovement));
255 float minimumSpace = (float)Math.Abs(viewPosition[i] - viewPosition[touchedViewIndex]);
256 if (currentSpace < minimumSpace)
258 movement = lastMovement;
261 // check views in screen are still moving or stopped.
262 float newPosition = viewPosition[i] + movement - lastMovement;
263 if (i >= leftIndex && i <= rightIndex)
265 Vector3 previousPosition = new Vector3();
266 GetPosition(viewId[i], previousPosition);
267 if (Math.Abs(previousPosition.X - newPosition) >= 1.0f)
269 isStillMoving = false;
272 // update new position.
273 SetPosition(viewId[i], new Vector3(newPosition, 0.0f, 0.0f));
275 isResetTouchedViewPossible = isStillMoving;
278 public override void OnUpdate(float elapsedSeconds)
280 // second -> millisecond
281 totalAnimationTime += elapsedSeconds * 1000.0f;
283 Vector3 currentPosition = new Vector3();
284 GetPosition(containerId, currentPosition);
286 // Add new Movement, if there is change in position.
287 // 1. if dirty(there is reserved event)
288 // 2. if container position is changed.
289 // 3. if every icons in screen is stopped
290 if (dirty || currentPosition.X != previousContainerPosition || isResetTouchedViewPossible)
293 if (totalAnimationTime >= containerMovement.Count * timeInterval)
295 // If the passed time is larger than timeInterval, add new movements.
296 // If we need to add more than one, compute each movement by using interpolation.
297 while (containerMovement.Count <= totalAnimationTime / timeInterval)
299 float factor = ((float)(containerMovement.Count * timeInterval) - previousTotalAnimationTime) / (totalAnimationTime - previousTotalAnimationTime);
300 float movement = (float)(factor * currentPosition.X + (1.0f - factor) * previousContainerPosition) - containerStartPosition;
301 AddMovement(movement);
304 // We need to compute velocity here to get reasonable value.
305 velocity = (currentPosition.X - previousContainerPosition) / (totalAnimationTime - previousTotalAnimationTime);
306 previousTotalAnimationTime = totalAnimationTime;
307 previousContainerPosition = currentPosition.X;
310 float currentMovement = currentPosition.X - containerStartPosition;
311 SetLatestMovement(currentMovement);
313 // Compute positions of each icon
314 ComputeNewPositions((int)totalAnimationTime);
316 // compute requiredMovementSize
317 if (requiredMovementSize == 0 || needUpdateMovementSize)
319 needUpdateMovementSize = false;
320 requiredMovementSize = viewId.Count * OBJECT_DELAY / timeInterval;
323 // Remove unnecessary movement for memory optimization.
324 if (containerMovement.Count > requiredMovementSize * 2)
326 int movementNumberToRemove = containerMovement.Count - requiredMovementSize;
327 containerMovement.RemoveRange(0, movementNumberToRemove);
328 totalAnimationTime -= (float)(timeInterval * movementNumberToRemove);
333 private Window window;
335 private FrameUpdateCallback frameUpdateCallback; ///< An instance of our implementation of the FrameUpdateCallbackInterface.
337 // Views for launcher
338 private View baseView;
339 private View controlView;
340 private View layoutView;
342 // Variables for animation
343 private float previousTouchedPosition;
344 private int touchedViewIndex;
345 private TOUCH_ANIMATION_STATE animationState;
347 private float leftDirectionLimit;
348 private float rightDirectionLimit;
351 // Variables for Finish animation
352 // These variables are for deceleration curve.
353 // If we want to use another curve like bezier, uses different variables
354 private delegate float UserAlphaFunctionDelegate(float progress);
355 private UserAlphaFunctionDelegate customScrollAlphaFunction;
356 private float absoluteVelocity = 0.0f;
357 private float finishAnimationDuration = 0.0f;
358 private float finishAnimationDelta = 0.0f;
359 private float logDeceleration = 0.0f;
360 private float decelerationRate = 0.99f;
361 private float easingThreshold = 0.1f;
363 private Animation finishAnimation;
364 private Timer animationOffTimer; // timer to end animation after the easing animation is finished
367 private View contentsView;
369 public void Activate()
371 frameUpdateCallback = new FrameUpdateCallback();
375 public void Deactivate()
381 // Set the stage background color and connect to the stage's key signal to allow Back and Escape to exit.
382 window = Window.Instance;
383 window.BackgroundColor = Color.White;
385 rightDirectionLimit = INITIAL_POSITION;
389 contentsView = new View();
390 contentsView.BackgroundColor = new Color(0.921568f, 0.9098039f, 0.890196f, 0.5f);
391 contentsView.ParentOrigin = ParentOrigin.TopLeft;
392 contentsView.PivotPoint = PivotPoint.TopLeft;
393 contentsView.PositionUsesPivotPoint = true;
394 contentsView.WidthResizePolicy = ResizePolicyType.FillToParent;
395 contentsView.HeightResizePolicy = ResizePolicyType.FillToParent;
396 window.GetDefaultLayer().Add(contentsView);
399 baseView = new View();
400 baseView.ParentOrigin = ParentOrigin.BottomLeft;
401 baseView.PivotPoint = PivotPoint.BottomLeft;
402 baseView.PositionUsesPivotPoint = true;
403 baseView.Size = new Size(window.Size.Width, 278);
404 baseView.Position = new Position(0, 0);
405 window.GetDefaultLayer().Add(baseView);
407 View iconBackgroundView = new View();
408 iconBackgroundView.BackgroundColor = new Color(0.921568f, 0.9098039f, 0.890196f, 0.5f);
409 iconBackgroundView.ParentOrigin = ParentOrigin.BottomLeft;
410 iconBackgroundView.PivotPoint = PivotPoint.BottomLeft;
411 iconBackgroundView.PositionUsesPivotPoint = true;
412 iconBackgroundView.Size = new Size(window.Size.Width, 278);
413 iconBackgroundView.Position = new Position(0, 0);
414 baseView.Add(iconBackgroundView);
416 controlView = new View();
417 controlView.ParentOrigin = ParentOrigin.CenterLeft;
418 controlView.PivotPoint = PivotPoint.CenterLeft;
419 controlView.PositionUsesPivotPoint = true;
420 controlView.Position = new Position(rightDirectionLimit, 0);
421 baseView.Add(controlView);
422 frameUpdateCallback.SetContainerId(controlView.ID);
424 layoutView = new View();
425 layoutView.ParentOrigin = ParentOrigin.CenterLeft;
426 layoutView.PivotPoint = PivotPoint.CenterLeft;
427 layoutView.PositionUsesPivotPoint = true;
428 layoutView.Layout = new LinearLayout()
430 LinearOrientation = LinearLayout.Orientation.Horizontal,
431 CellPadding = new Size2D(DEFAULT_SPACE, 0),
433 layoutView.Position = new Position(0, 0);
434 controlView.Add(layoutView);
436 for (int i = 0; i < 4; ++i)
438 AddIcon(BACKGROUND_IMAGE_PATH[i], APPS_IMAGE_PATH[i], APPS_ICON_NAME[i], Color.White);
441 View divideBar = new View();
442 divideBar.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.1f);
443 divideBar.ParentOrigin = ParentOrigin.CenterLeft;
444 divideBar.PivotPoint = PivotPoint.CenterLeft;
445 divideBar.PositionUsesPivotPoint = true;
446 divideBar.Size = new Size(DEVIDE_BAR_SIZE, OBJECT_SIZE);
447 layoutView.Add(divideBar);
448 frameUpdateCallback.AddId(divideBar.ID);
451 for (int i = 0; i < iconNumber; ++i)
453 AddIcon(BACKGROUND_IMAGE_PATH[5], CONTROL_IMAGE_PATH[i % 5], CONTROL_ICON_NAME[i % 5], new Color(0.0f, 0.0f, 0.0f, 0.5f));
456 frameUpdateCallback.ResetViewPosition();
457 frameUpdateCallback.SetTimeInterval(1000 / FRAME_RATE);
459 animationState = TOUCH_ANIMATION_STATE.NO_ANIMATION;
461 animationOffTimer = new Timer(16);
462 animationOffTimer.Tick += OffAnimatable;
464 baseView.TouchEvent += OnTouch;
466 finishAnimation = new Animation();
467 finishAnimation.Finished += EasingAnimationFinishedCallback;
468 logDeceleration = (float)Math.Log(decelerationRate);
473 void AddIcon(string background, string icon, string text, Color textColor)
475 ImageView backgroundView = new ImageView();
476 backgroundView.ResourceUrl = background;
477 backgroundView.Size = new Size(OBJECT_SIZE, OBJECT_SIZE);
478 backgroundView.ParentOrigin = ParentOrigin.CenterLeft;
479 backgroundView.PivotPoint = PivotPoint.CenterLeft;
480 backgroundView.PositionUsesPivotPoint = true;
481 layoutView.Add(backgroundView);
482 frameUpdateCallback.AddId(backgroundView.ID);
484 ImageView iconView = new ImageView();
485 iconView.ResourceUrl = icon;
486 iconView.Position = new Position(0, -15);
487 iconView.ParentOrigin = ParentOrigin.Center;
488 iconView.PivotPoint = PivotPoint.Center;
489 iconView.PositionUsesPivotPoint = true;
490 backgroundView.Add(iconView);
492 TextLabel label = new TextLabel(text);
493 label.Position = new Position(0, 30);
494 label.HorizontalAlignment = HorizontalAlignment.Center;
495 label.TextColor = textColor;
496 label.FontFamily = "SamsungOneUI";
497 label.PointSize = 12;
498 label.ParentOrigin = ParentOrigin.Center;
499 label.PivotPoint = PivotPoint.Center;
500 label.PositionUsesPivotPoint = true;
501 backgroundView.Add(label);
504 // Set frame callback to start drag animation.
505 private void SetFrameUpdateCallback(float position)
507 // remove frame callback if it is already added.
508 window.RemoveFrameUpdateCallback(frameUpdateCallback);
510 frameUpdateCallback.ResetAnimationData();
511 frameUpdateCallback.AddMovement(0.0f); // Add first movement.
513 // Set container start position and start positions of each icon(and vertical bar)
514 // And compute total container size.
515 float totalSize = 0.0f;
516 frameUpdateCallback.SetContainerStartPosition(controlView.Position.X);
517 for (int i = 0; i < layoutView.ChildCount; ++i)
519 frameUpdateCallback.SetViewPosition(i, layoutView.Children[i].Position.X);
520 totalSize += (float)(layoutView.Children[i].Size.Width + DEFAULT_SPACE);
522 totalSize -= (float)DEFAULT_SPACE;
525 for (int i = (int)layoutView.ChildCount - 1; i >= 0; --i)
527 if (position >= layoutView.Children[i].Position.X + controlView.Position.X)
529 frameUpdateCallback.SetTouchedViewIndex(i);
530 touchedViewIndex = i;
534 if (position < layoutView.Children[0].Position.X + controlView.Position.X)
536 frameUpdateCallback.SetTouchedViewIndex(0);
537 touchedViewIndex = 0;
540 previousTouchedPosition = position;
542 // Add frame callback on window.
543 // OnUpdate callback of frameUpdateCallback will be called before every render frame.
544 window.AddFrameUpdateCallback(frameUpdateCallback);
546 // compute limit position the container could go.
547 leftDirectionLimit = (float)window.Size.Width - (totalSize + (float)(INITIAL_POSITION));
549 window.RenderingBehavior = RenderingBehaviorType.Continuously; // make rendering be done for upto 60 fps even though there is no update in main thread.
550 animationState = TOUCH_ANIMATION_STATE.ON_ANIMATION; // make rendering state on.
553 private bool OnTouch(object source, View.TouchEventArgs e)
555 Vector2 position = e.Touch.GetScreenPosition(0);
557 PointStateType state = e.Touch.GetState(0);
558 if (PointStateType.Down == state)
560 if (animationState == TOUCH_ANIMATION_STATE.ON_FINISH_ANIMATION)
562 // re-birth current animation
563 // in case of touch during finish animation,
564 // quit easingAnimation and AnimationOffTimer because animation ownership is returned to the touch event again.
565 // AND, DO NOT RESET ALL PROPERTIES OF FRAMECALLBACK.
566 // because, for example, if touched icon index is changed, the movement is wrong and the animation can be not continous.
567 // This re-birthed animation is just for smooth moving during complex user interaction.
568 // during complex and fast interaction, this is not so noticeable.
569 // and reset of such properties will be done in the below Motion state
570 finishAnimation.Stop();
571 animationOffTimer.Stop();
573 // Set Animation State to ON_ANIMATION again
574 animationState = TOUCH_ANIMATION_STATE.ON_ANIMATION;
575 // Set previousTouchPosition
576 previousTouchedPosition = position.X;
580 // in case of stable state
581 // just set new framecallback for this touched position.
582 SetFrameUpdateCallback(position.X);
585 else if (PointStateType.Motion == state)
587 // if framecallback can be reset, quit current frame callback and re-launch new frame callback.
588 // because, if current frame callback is re-birthed one, the animation is not totally re-created one.
589 // So, some properties like touched icon index can be wrong for the continuous animation.
590 // But, some case like that finger is stopped and restart to move, this could make weired feeling.
591 // We reset frameUpdateCallback as soon as possible we can. And the conditions are ...
592 // 1. icons in screen is stopped.
593 // 2. velocity of frame callback is 0.0 (this frame callback will not move again instantly)
594 // 3. frame callback is not dirty (there is no reserved action)
595 if (frameUpdateCallback.IsResetTouchedViewPossible() && frameUpdateCallback.GetVelocity() == 0.0f && !frameUpdateCallback.IsDirty())
597 SetFrameUpdateCallback(position.X);
600 // Set new controlView(container) position
601 // in here, we need to consider the container is not go outside of limits.
602 float containerPosition = controlView.Position.X + (position.X - previousTouchedPosition);
603 containerPosition = Math.Min(containerPosition, rightDirectionLimit);
604 containerPosition = Math.Max(containerPosition, leftDirectionLimit);
605 float adjustedPosition = containerPosition - controlView.Position.X + previousTouchedPosition;
606 previousTouchedPosition = adjustedPosition;
607 controlView.Position.X = containerPosition;
609 else if ((PointStateType.Up == state || PointStateType.Leave == state || PointStateType.Interrupted == state) &&
610 animationState == TOUCH_ANIMATION_STATE.ON_ANIMATION)
612 animationState = TOUCH_ANIMATION_STATE.ON_FINISH_ANIMATION;
614 // To launch finish animation, we get latest velocty from frame callback
615 float lastVelocity = frameUpdateCallback.GetVelocity();
618 // This is just for turning of finish animation.
619 // change the values if you want.
620 lastVelocity = Math.Max(lastVelocity, -3.5f);
621 lastVelocity = Math.Min(lastVelocity, 3.5f);
622 if (Math.Abs(lastVelocity) < 0.0001f)
624 // If velocity is zero. just start animationOfftimer.
625 animationOffTimer.Start();
629 // If velocity is not zero, make decelerating animation.
630 Decelerating(lastVelocity);
633 // set currently visible icons for optimization
635 // make frame callback dirty.
636 frameUpdateCallback.Dirty();
640 private void SetVisibleLimit()
642 int leftViewIndex = touchedViewIndex;
643 for (; leftViewIndex >= 0; --leftViewIndex)
645 float newPosition = layoutView.Children[leftViewIndex].Position.X + controlView.Position.X;
646 if (newPosition + (float)layoutView.Children[leftViewIndex].Size.Width < 0.0f)
651 leftViewIndex = Math.Max(leftViewIndex, 0);
652 int rightViewIndex = touchedViewIndex;
653 for (; rightViewIndex < layoutView.ChildCount; ++rightViewIndex)
655 float newPosition = layoutView.Children[rightViewIndex].Position.X + controlView.Position.X;
656 if (newPosition > window.Size.Width)
661 rightViewIndex = Math.Min(rightViewIndex, (int)layoutView.ChildCount - 1);
663 frameUpdateCallback.SetLeftIndex(leftViewIndex);
664 frameUpdateCallback.SetRightIndex(rightViewIndex);
667 // set decelerating properties
668 // in this example, we used decelerate animation in "https://medium.com/@esskeetit/scrolling-mechanics-of-uiscrollview-142adee1142c"
669 // But, if this method is problematic or violate some patent of other company, change this other way.
670 // We didn't checked anything.
671 // Only thing we need to remember when we change this animation is to add "EasingAnimationFinishedCallback" for the new animation.
672 private void Decelerating(float lastVelocity)
674 absoluteVelocity = Math.Abs(lastVelocity);
675 finishAnimationDelta = (absoluteVelocity * decelerationRate) / (1 - decelerationRate);
676 float destination = (lastVelocity > 0) ? controlView.Position.X + finishAnimationDelta : controlView.Position.X - finishAnimationDelta;
678 if (destination < leftDirectionLimit || destination > rightDirectionLimit)
680 finishAnimationDelta = lastVelocity > 0 ? (rightDirectionLimit - controlView.Position.X) : (controlView.Position.X - leftDirectionLimit);
681 destination = lastVelocity > 0 ? rightDirectionLimit : leftDirectionLimit;
682 if (finishAnimationDelta == 0)
684 finishAnimationDuration = 0.0f;
688 finishAnimationDuration = (float)Math.Log((finishAnimationDelta * logDeceleration / absoluteVelocity + 1), decelerationRate);
693 if (finishAnimationDelta == 0)
695 finishAnimationDuration = 0.0f;
699 finishAnimationDuration = (float)Math.Log(-easingThreshold * logDeceleration / absoluteVelocity) / logDeceleration;
703 finishAnimation.Clear();
704 customScrollAlphaFunction = new UserAlphaFunctionDelegate(CustomScrollAlphaFunction);
705 finishAnimation.DefaultAlphaFunction = new AlphaFunction(customScrollAlphaFunction);
706 GC.KeepAlive(customScrollAlphaFunction);
707 finishAnimation.Duration = (int)finishAnimationDuration;
708 finishAnimation.AnimateTo(controlView, "PositionX", destination);
709 finishAnimation.Play();
712 private float CustomScrollAlphaFunction(float progress)
714 if (finishAnimationDelta == 0)
720 float realDuration = progress * finishAnimationDuration;
721 float realDistance = absoluteVelocity * ((float)Math.Pow(decelerationRate, realDuration) - 1) / logDeceleration;
722 float result = Math.Min(realDistance / Math.Abs(finishAnimationDelta), 1.0f);
728 private void EasingAnimationFinishedCallback(object sender, EventArgs e)
730 if (animationState != TOUCH_ANIMATION_STATE.ON_FINISH_ANIMATION)
735 // start Animation Off Timer
736 finishAnimation.Clear();
738 animationOffTimer.Start();
741 // Check each icons in screen is not moving.
742 // If it is, finish all animation and make animationstate End_animation(NO_ANIMATION)
743 private bool OffAnimatable(object target, Timer.TickEventArgs args)
745 if (frameUpdateCallback.IsResetTouchedViewPossible())
747 window.RenderingBehavior = RenderingBehaviorType.IfRequired;
748 window.RemoveFrameUpdateCallback(frameUpdateCallback);
749 animationOffTimer.Stop();
750 animationState = TOUCH_ANIMATION_STATE.END_ANIMATION;