Merge pull request #15399 from geemedia/pageview-turning-time-configurable

Make PageView page turning event time tweak configurable.
This commit is contained in:
zilongshanren 2016-04-11 04:50:46 -05:00
commit abfce2617e
3 changed files with 16 additions and 2 deletions

View File

@ -38,7 +38,8 @@ _currentPageIndex(-1),
_childFocusCancelOffset(5.0f),
_pageViewEventListener(nullptr),
_pageViewEventSelector(nullptr),
_eventCallback(nullptr)
_eventCallback(nullptr),
_autoScrollStopEpsilon(0.001f)
{
}
@ -177,6 +178,11 @@ bool PageView::isUsingCustomScrollThreshold()const
return false;
}
void PageView::setAutoScrollStopEpsilon(float epsilon)
{
_autoScrollStopEpsilon = epsilon;
}
void PageView::moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack)
{
ListView::moveInnerContainer(deltaMove, canStartBounceBack);
@ -263,7 +269,7 @@ void PageView::handleReleaseLogic(Touch *touch)
float PageView::getAutoScrollStopEpsilon() const
{
return 0.001;
return _autoScrollStopEpsilon;
}
void PageView::pageTurningEvent()

View File

@ -341,6 +341,8 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE bool isUsingCustomScrollThreshold()const;
void setAutoScrollStopEpsilon(float epsilon);
CC_CONSTRUCTOR_ACCESS:
virtual bool init() override;
@ -384,6 +386,7 @@ protected:
#pragma warning (pop)
#endif
ccPageViewCallback _eventCallback;
float _autoScrollStopEpsilon;
};
}

View File

@ -545,6 +545,11 @@ void ScrollView::processAutoScrolling(float deltaTime)
Vec2 newPosition = _autoScrollStartPosition + (_autoScrollTargetDelta * percentage);
bool reachedEnd = fabs(percentage - 1) <= this->getAutoScrollStopEpsilon();
if (reachedEnd)
{
newPosition = _autoScrollStartPosition + _autoScrollTargetDelta;
}
if(_bounceEnabled)
{
// The new position is adjusted if out of boundary