mirror of https://github.com/axmolengine/axmol.git
ScrollView - Add a guard statement in setContentSize() to avoid resetting inner container's position if not necessary.
This commit is contained in:
parent
4022fb65e1
commit
7f9c8acc2a
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue