Bladeren bron

fixed permanent container bounds updating when scrollable area is lesser than container's area

Andrew Karpushin 10 jaren geleden
bovenliggende
commit
f98dbf579a
1 gewijzigde bestanden met toevoegingen van 5 en 4 verwijderingen
  1. 5 4
      gameplay/src/Container.cpp

+ 5 - 4
gameplay/src/Container.cpp

@@ -1138,34 +1138,35 @@ void Container::updateScroll()
     }
     }
 
 
     // Stop scrolling when the far edge is reached.
     // Stop scrolling when the far edge is reached.
+    Vector2 lastScrollPosition(_scrollPosition);
+
     if (-_scrollPosition.x > _totalWidth - clipWidth)
     if (-_scrollPosition.x > _totalWidth - clipWidth)
     {
     {
         _scrollPosition.x = -(_totalWidth - clipWidth);
         _scrollPosition.x = -(_totalWidth - clipWidth);
         _scrollingVelocity.x = 0;
         _scrollingVelocity.x = 0;
-        dirty = true;
     }
     }
     
     
     if (-_scrollPosition.y > _totalHeight - clipHeight)
     if (-_scrollPosition.y > _totalHeight - clipHeight)
     {
     {
         _scrollPosition.y = -(_totalHeight - clipHeight);
         _scrollPosition.y = -(_totalHeight - clipHeight);
         _scrollingVelocity.y = 0;
         _scrollingVelocity.y = 0;
-        dirty = true;
     }
     }
 
 
     if (_scrollPosition.x > 0)
     if (_scrollPosition.x > 0)
     {
     {
         _scrollPosition.x = 0;
         _scrollPosition.x = 0;
         _scrollingVelocity.x = 0;
         _scrollingVelocity.x = 0;
-        dirty = true;
     }
     }
 
 
     if (_scrollPosition.y > 0)
     if (_scrollPosition.y > 0)
     {
     {
         _scrollPosition.y = 0;
         _scrollPosition.y = 0;
         _scrollingVelocity.y = 0;
         _scrollingVelocity.y = 0;
-        dirty = true;
     }
     }
 
 
+    if (_scrollPosition != lastScrollPosition)
+        dirty = true;
+
     float scrollWidth = 0;
     float scrollWidth = 0;
     if (clipWidth < _totalWidth)
     if (clipWidth < _totalWidth)
         scrollWidth = (clipWidth / _totalWidth) * clipWidth;
         scrollWidth = (clipWidth / _totalWidth) * clipWidth;