issue #5183, refactor UIScrollView

This commit is contained in:
andyque 2014-05-19 17:34:48 +08:00
parent ee24e137f7
commit a9e1c50897
2 changed files with 329 additions and 297 deletions

View File

@ -858,14 +858,10 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
return scrollenabled;
}
bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY)
bool ScrollView::scrollChilderVertical(float touchOffsetX, float touchOffsetY)
{
bool scrollenabled = true;
scrollingEvent();
switch (_direction)
{
case Direction::VERTICAL: // vertical
{
float realOffset = touchOffsetY;
if (_bounceEnabled)
{
@ -902,10 +898,14 @@ bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY)
}
}
moveChildren(0.0f, realOffset);
break;
}
case Direction::HORIZONTAL: // horizontal
{
return scrollenabled;
}
bool ScrollView::scrollChilderHorizontal(float touchOffsetX, float touchOffsetY)
{
bool scrollenabled = true;
float realOffset = touchOffsetX;
if (_bounceEnabled)
{
@ -942,10 +942,13 @@ bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY)
}
}
moveChildren(realOffset, 0.0f);
break;
}
case Direction::BOTH:
{
return scrollenabled;
}
bool ScrollView::scrollChilderBoth(float touchOffsetX, float touchOffsetY)
{
bool scrollenabled = true;
float realOffsetX = touchOffsetX;
float realOffsetY = touchOffsetY;
if (_bounceEnabled)
@ -1171,6 +1174,29 @@ bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY)
}
}
moveChildren(realOffsetX, realOffsetY);
return scrollenabled;
}
bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY)
{
bool scrollenabled = true;
scrollingEvent();
switch (_direction)
{
case Direction::VERTICAL: // vertical
{
scrollenabled = this->scrollChilderVertical(touchOffsetX, touchOffsetY);
break;
}
case Direction::HORIZONTAL: // horizontal
{
scrollenabled = this->scrollChilderHorizontal(touchOffsetX, touchOffsetY);
break;
}
case Direction::BOTH:
{
scrollenabled = this->scrollChilderBoth(touchOffsetX, touchOffsetY);
break;
}
default:

View File

@ -356,7 +356,13 @@ protected:
void startBounceChildren(float v);
void stopBounceChildren();
bool checkCustomScrollDestination(float* touchOffsetX, float* touchOffsetY);
virtual bool scrollChildren(float touchOffsetX, float touchOffsetY);
virtual bool scrollChilderHorizontal(float touchOffsetX, float touchOffsetY);
virtual bool scrollChilderVertical(float touchOffsetX, float touchOffsetY);
virtual bool scrollChilderBoth(float touchOffsetX, float touchOffsetY);
bool bounceScrollChildren(float touchOffsetX, float touchOffsetY);
void startRecordSlidAction();
virtual void endRecordSlidAction();