From b26d446b0cb6a316abc3a79d4fc70d0ae1b7994c Mon Sep 17 00:00:00 2001 From: György Straub Date: Wed, 9 Sep 2020 15:49:51 +0100 Subject: [PATCH] Fixed DGEUF-1841. --- examples/drag-and-drop/drag-and-drop-example.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/drag-and-drop/drag-and-drop-example.cpp b/examples/drag-and-drop/drag-and-drop-example.cpp index 22e733f..b9e7f08 100644 --- a/examples/drag-and-drop/drag-and-drop-example.cpp +++ b/examples/drag-and-drop/drag-and-drop-example.cpp @@ -44,6 +44,8 @@ const float TEXT_LABEL_WIDTH = 250.0f; const float TEXT_LABEL_HEIGHT = 70.0f; const unsigned int TEXT_LABEL_NUM = sizeof(TEXT_LABEL_COLOR) / sizeof(TEXT_LABEL_COLOR[0]); +const float DROP_ANIMATION_DURATION_S = 0.5f; + #if defined(DEBUG_ENABLED) Debug::Filter* gDragAndDropFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_DRAG_AND_DROP_EXAMPLE"); #endif @@ -183,14 +185,14 @@ public: } } - Animation mAnimation = Animation::New(0.5f); + Animation mAnimation = Animation::New(DROP_ANIMATION_DURATION_S); if(droppedIndex > mDragIndex) { for(int i = mDragIndex + 1; i <= droppedIndex; i++) { - float y = mTextLabel[mOrder[i]].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y; - mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), Vector3(TEXT_LABEL_POSITION_X, y - TEXT_LABEL_HEIGHT, 0.0f), AlphaFunction::EASE_OUT); + mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), + Vector3(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * (i - 1), 0.0f), AlphaFunction::EASE_OUT); mAnimation.Play(); } @@ -204,11 +206,10 @@ public: } else if(droppedIndex < mDragIndex) { - for(int i = mDragIndex - 1; i >= droppedIndex; i--) { - float y = mTextLabel[mOrder[i]].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y; - mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), Vector3(TEXT_LABEL_POSITION_X, y + TEXT_LABEL_HEIGHT, 0.0f), AlphaFunction::EASE_OUT); + mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), + Vector3(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * (i + 1), 0.0f), AlphaFunction::EASE_OUT); mAnimation.Play(); } @@ -219,23 +220,21 @@ public: } mOrder[droppedIndex] = tmpId; - } - Vector2 pos = detector.GetCurrentScreenPosition(); Vector2 localPos; control.GetParent().ScreenToLocal(localPos.x, localPos.y, pos.x, pos.y); KeyFrames k0 = KeyFrames::New(); k0.Add(0.0f, Vector3(localPos.x - mDragLocalPos.x, localPos.y - mDragLocalPos.y, 0.0f)); - k0.Add(1.0f, Vector3(control.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, control.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, 0.0f)); + k0.Add(1.0f, Vector3(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * droppedIndex, 0.0f)); KeyFrames k1 = KeyFrames::New(); k1.Add(0.0f, 0.1f); k1.Add(1.0f, 1.0f); - Animation dropAnimation = Animation::New(0.5f); + Animation dropAnimation = Animation::New(DROP_ANIMATION_DURATION_S); dropAnimation.AnimateBetween(Property(mTextLabel[mDragRealIndex], Actor::Property::POSITION), k0, AlphaFunction::EASE_OUT); dropAnimation.AnimateBetween(Property(mTextLabel[mDragRealIndex], Actor::Property::OPACITY), k1, AlphaFunction::EASE_OUT); dropAnimation.Play(); -- libgit2 0.21.4