ScrollView - Add a guard statement in setContentSize() to avoid resetting inner container's position if not necessary.

This commit is contained in:
Neo Kim 2015-09-13 19:36:22 +09:00
parent 4022fb65e1
commit 7f9c8acc2a
2 changed files with 11 additions and 1 deletions

View File

@ -997,6 +997,16 @@ void ScrollView::update(float dt)
}
}
void ScrollView::setContentSize(const cocos2d::Size &contentSize)
{
Size previousSize = Layout::getContentSize();
if(previousSize.equals(contentSize))
{
return;
}
Layout::setContentSize(contentSize);
}
void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sender,Touch* touch)
{
if(!_touchEnabled)

View File

@ -357,7 +357,7 @@ public:
virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override;
virtual void onTouchCancelled(Touch *touch, Event *unusedEvent) override;
virtual void update(float dt) override;
virtual void setContentSize(const Size &contentSize) override;
/**
* @brief Toggle bounce enabled when scroll to the edge.