diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 850d45c0e..8973ac7a9 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -222,7 +222,9 @@ std::vector SystemView::getHelpPrompts() void SystemView::onCursorChanged(const CursorState& state) { - int cursor {mPrimary->getCursor()}; + const int cursor {mPrimary->getCursor()}; + const std::string& transitionStyle {Settings::getInstance()->getString("TransitionStyle")}; + mFadeTransitions = transitionStyle == "fade"; // Avoid double updates. if (cursor != mLastCursor) { @@ -237,6 +239,33 @@ void SystemView::onCursorChanged(const CursorState& state) video->stopVideoPlayer(); } + const int scrollVelocity {mPrimary->getScrollingVelocity()}; + + // This is needed to avoid erratic camera movements during extreme navigation input when using + // slide transitions. This should very rarely occur during normal application usage. + if (transitionStyle == "slide") { + bool resetCamOffset {false}; + + if (scrollVelocity == -1 && mPreviousScrollVelocity == 1) { + if (mLastCursor > cursor && mCamOffset > static_cast(mLastCursor)) + resetCamOffset = true; + else if (mLastCursor > cursor && mCamOffset < static_cast(cursor)) + resetCamOffset = true; + else if (mLastCursor < cursor && mCamOffset <= static_cast(cursor) && + mCamOffset != static_cast(mLastCursor)) + resetCamOffset = true; + } + else if (scrollVelocity == 1 && mPreviousScrollVelocity == -1) { + if (mLastCursor > cursor && mCamOffset < static_cast(mLastCursor)) + resetCamOffset = true; + else if (mLastCursor < cursor && mCamOffset > static_cast(cursor)) + resetCamOffset = true; + } + + if (resetCamOffset) + mCamOffset = static_cast(cursor); + } + mLastCursor = cursor; for (auto& video : mSystemElements[cursor].videoComponents) @@ -252,10 +281,9 @@ void SystemView::onCursorChanged(const CursorState& state) startViewVideos(); updateHelpPrompts(); - int scrollVelocity {mPrimary->getScrollingVelocity()}; + const float posMax {static_cast(mPrimary->getNumEntries())}; + const float target {static_cast(cursor)}; float startPos {mCamOffset}; - float posMax {static_cast(mPrimary->getNumEntries())}; - float target {static_cast(cursor)}; float endPos {target}; if (mPreviousScrollVelocity > 0 && scrollVelocity == 0 && mCamOffset > posMax - 1.0f) @@ -287,9 +315,6 @@ void SystemView::onCursorChanged(const CursorState& state) if (scrollVelocity != 0) mPreviousScrollVelocity = scrollVelocity; - std::string transitionStyle {Settings::getInstance()->getString("TransitionStyle")}; - mFadeTransitions = transitionStyle == "fade"; - Animation* anim; float animTime {380.0f};