Merge pull request #14907 from neokim/feature/scroll_view_touch_total_time_threshold

Add a setter for touch total time threshold in ScrollView
This commit is contained in:
zilongshanren 2016-01-21 10:31:31 +08:00
commit 061c6c7c6f
2 changed files with 27 additions and 1 deletions

View File

@ -59,6 +59,7 @@ _rightBoundary(0.0f),
_bePressed(false),
_childFocusCancelOffsetInInch(MOVE_INCH),
_touchMovePreviousTimestamp(0),
_touchTotalTimeThreshold(0.5f),
_autoScrolling(false),
_autoScrollAttenuate(true),
_autoScrollTotalTime(0),
@ -328,7 +329,7 @@ Vec2 ScrollView::calculateTouchMoveVelocity() const
{
totalTime += timeDelta;
}
if(totalTime == 0 || totalTime >= 0.5f)
if(totalTime == 0 || totalTime >= _touchTotalTimeThreshold)
{
return Vec2::ZERO;
}
@ -1304,6 +1305,16 @@ float ScrollView::getScrollBarAutoHideTime() const
return 0;
}
void ScrollView::setTouchTotalTimeThreshold(float touchTotalTimeThreshold)
{
_touchTotalTimeThreshold = touchTotalTimeThreshold;
}
float ScrollView::getTouchTotalTimeThreshold() const
{
return _touchTotalTimeThreshold;
}
Layout* ScrollView::getInnerContainer()const
{
return _innerContainer;

View File

@ -505,6 +505,20 @@ public:
*/
float getScrollBarAutoHideTime() const;
/**
* @brief Set the touch total time threshold
*
* @param the touch total time threshold
*/
void setTouchTotalTimeThreshold(float touchTotalTimeThreshold);
/**
* @brief Get the touch total time threshold
*
* @return the touch total time threshold
*/
float getTouchTotalTimeThreshold() const;
/**
* Set layout type for scrollview.
*
@ -620,6 +634,7 @@ protected:
std::list<Vec2> _touchMoveDisplacements;
std::list<float> _touchMoveTimeDeltas;
long long _touchMovePreviousTimestamp;
float _touchTotalTimeThreshold;
bool _autoScrolling;
bool _autoScrollAttenuate;