From b9d294f5423d00931b480542344c0e0b097150c0 Mon Sep 17 00:00:00 2001 From: Daiki Asahi Date: Sat, 14 Mar 2015 19:06:49 +0900 Subject: [PATCH] Fix container view's anchor point problem. --- extensions/GUI/CCScrollView/CCScrollView.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index b72a45244a..3ce6254d23 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -388,13 +388,20 @@ void ScrollView::relocateContainer(bool animated) Vec2 ScrollView::maxContainerOffset() { - return Vec2(0.0f, 0.0f); + Point anchorPoint = _container->isIgnoreAnchorPointForPosition()?Point::ZERO:_container->getAnchorPoint(); + float contW = _container->getContentSize().width * _container->getScaleX(); + float contH = _container->getContentSize().height * _container->getScaleY(); + + return Vec2(anchorPoint.x * contW, anchorPoint.y * contH); } Vec2 ScrollView::minContainerOffset() { - return Vec2(_viewSize.width - _container->getContentSize().width*_container->getScaleX(), - _viewSize.height - _container->getContentSize().height*_container->getScaleY()); + Point anchorPoint = _container->isIgnoreAnchorPointForPosition()?Point::ZERO:_container->getAnchorPoint(); + float contW = _container->getContentSize().width * _container->getScaleX(); + float contH = _container->getContentSize().height * _container->getScaleY(); + + return Vec2(_viewSize.width - (1 - anchorPoint.x) * contW, _viewSize.height - (1 - anchorPoint.y) * contH); } void ScrollView::deaccelerateScrolling(float dt)