@@ -595,9 +595,9 @@ void SceneObjectsListDrawer::updateSceneWindowScrollIfNeeded_()
595595 scrollInfo.relativeMousePos = ImGui::GetMousePos ().y - window->Pos .y ;
596596 scrollInfo.absLinePosRatio = window->ContentSize .y == 0 .0f ? 0 .0f : ( scrollInfo.relativeMousePos + window->Scroll .y ) / window->ContentSize .y ;
597597
598- if ( nextFrameFixScroll_ )
598+ if ( dragModeTrigger_ )
599599 {
600- nextFrameFixScroll_ = false ;
600+ dragModeTrigger_ = false ;
601601 window->Scroll .y = std::clamp ( prevScrollInfo_.absLinePosRatio * window->ContentSize .y - prevScrollInfo_.relativeMousePos , 0 .0f , window->ScrollMax .y );
602602 }
603603 else if ( dragObjectsMode_ )
@@ -616,23 +616,39 @@ void SceneObjectsListDrawer::updateSceneWindowScrollIfNeeded_()
616616 getViewerInstance ().incrementForceRedrawFrames ();
617617 }
618618 }
619+ else if ( nextFrameFixScroll_ )
620+ {
621+ nextFrameFixScroll_ = false ;
622+ float absPos = prevScrollInfo_.absLinePosRatio * window->ContentSize .y - window->Scroll .y ;
623+ float addScroll = 0 .0f ;
624+ if ( absPos < 15 * UI::scale () )
625+ addScroll = absPos - 15 * UI::scale ();
626+ else if ( absPos > window->Size .y - 15 * UI::scale () )
627+ addScroll = absPos - ( window->Size .y - 15 * UI::scale () );
628+ auto newScroll = std::clamp ( window->Scroll .y + addScroll, 0 .0f , window->ScrollMax .y );
629+ if ( newScroll != window->Scroll .y )
630+ {
631+ window->Scroll .y = newScroll;
632+ getViewerInstance ().incrementForceRedrawFrames ();
633+ }
634+ }
619635
620636 const ImGuiPayload* payloadCheck = ImGui::GetDragDropPayload ();
621637 bool dragModeNow = payloadCheck && std::string_view ( payloadCheck->DataType ) == " _TREENODE" ;
622638 if ( dragModeNow && !dragObjectsMode_ )
623639 {
624640 dragObjectsMode_ = true ;
625- nextFrameFixScroll_ = true ;
641+ dragModeTrigger_ = true ;
626642 getViewerInstance ().incrementForceRedrawFrames ( 2 , true );
627643 }
628644 else if ( !dragModeNow && dragObjectsMode_ )
629645 {
630646 dragObjectsMode_ = false ;
631- nextFrameFixScroll_ = true ;
647+ dragModeTrigger_ = true ;
632648 getViewerInstance ().incrementForceRedrawFrames ( 2 , true );
633649 }
634650
635- if ( !nextFrameFixScroll_ )
651+ if ( !dragModeTrigger_ )
636652 prevScrollInfo_ = scrollInfo;
637653}
638654
0 commit comments