diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 117afd0c2..c4c1cb09f 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -32,6 +32,7 @@ namespace SystemView::SystemView() : mCamOffset {0.0f} , mFadeOpacity {0.0f} + , mPreviousScrollVelocity {0} , mUpdatedGameCount {false} , mViewNeedsReload {true} , mLegacyMode {false} @@ -240,6 +241,20 @@ void SystemView::onCursorChanged(const CursorState& /*state*/) if (fabs(target - posMax - startPos - scrollVelocity) < dist) endPos = target - posMax; // Loop around the start (max - 1 -> -1). + // Make sure transitions do not animate in reverse. + bool changedDirection {false}; + if (mPreviousScrollVelocity != 0 && mPreviousScrollVelocity != scrollVelocity) + changedDirection = true; + + if (!changedDirection && scrollVelocity > 0 && endPos < startPos) + endPos = endPos + posMax; + + if (!changedDirection && scrollVelocity < 0 && endPos > startPos) + endPos = endPos - posMax; + + if (scrollVelocity != 0) + mPreviousScrollVelocity = scrollVelocity; + std::string transition_style {Settings::getInstance()->getString("TransitionStyle")}; Animation* anim; diff --git a/es-app/src/views/SystemView.h b/es-app/src/views/SystemView.h index 4ae658701..a4e6cdeab 100644 --- a/es-app/src/views/SystemView.h +++ b/es-app/src/views/SystemView.h @@ -90,6 +90,7 @@ private: float mCamOffset; float mFadeOpacity; + int mPreviousScrollVelocity; bool mUpdatedGameCount; bool mViewNeedsReload; diff --git a/es-core/src/components/CarouselComponent.cpp b/es-core/src/components/CarouselComponent.cpp index 185cbbcae..1c2fd2821 100644 --- a/es-core/src/components/CarouselComponent.cpp +++ b/es-core/src/components/CarouselComponent.cpp @@ -435,23 +435,19 @@ void CarouselComponent::onCursorChanged(const CursorState& state) if (fabs(target - posMax - startPos - mScrollVelocity) < dist) endPos = target - posMax; // Loop around the start (max - 1 -> -1). - // This logic is only needed when there are two game systems, to prevent ugly jumps back - // an forth when selecting the same direction rapidly several times in a row. - if (posMax == 2) { - if (mPreviousScrollVelocity == 0) - mPreviousScrollVelocity = mScrollVelocity; - else if (mScrollVelocity < 0 && startPos < endPos) - mPreviousScrollVelocity = -1; - else if (mScrollVelocity > 0 && startPos > endPos) - mPreviousScrollVelocity = 1; - } - if (mPreviousScrollVelocity != 0 && posMax == 2 && mScrollVelocity == mPreviousScrollVelocity) { - if (fabs(endPos - startPos) < 0.5 || fabs(endPos - startPos) > 1.5) { - (mScrollVelocity < 0) ? endPos -= 1 : endPos += 1; - (mCursor == 0) ? mCursor = 1 : mCursor = 0; - return; - } - } + // Make sure there are no reverse jumps between logos. + bool changedDirection {false}; + if (mPreviousScrollVelocity != 0 && mPreviousScrollVelocity != mScrollVelocity) + changedDirection = true; + + if (!changedDirection && mScrollVelocity > 0 && endPos < startPos) + endPos = endPos + posMax; + + if (!changedDirection && mScrollVelocity < 0 && endPos > startPos) + endPos = endPos - posMax; + + if (mScrollVelocity != 0) + mPreviousScrollVelocity = mScrollVelocity; // No need to animate transition, we're not going anywhere (probably mEntries.size() == 1). if (endPos == mCamOffset)