From 805be977fed5ad0ebf6aceec9d68b1ef815a378c Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 4 Feb 2016 15:24:06 +0800 Subject: [PATCH] tweak PageView page turning event time. --- cocos/ui/UIPageView.cpp | 5 +++++ cocos/ui/UIPageView.h | 1 + cocos/ui/UIScrollView.cpp | 7 ++++++- cocos/ui/UIScrollView.h | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 183c6354b1..2e0eb7b036 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -260,6 +260,11 @@ void PageView::handleReleaseLogic(Touch *touch) } } } + +float PageView::getAutoScrollStopEpsilon() +{ + return 0.001; +} void PageView::pageTurningEvent() { diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 246f99100c..b364599824 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -349,6 +349,7 @@ CC_CONSTRUCTOR_ACCESS: protected: void pageTurningEvent(); + virtual float getAutoScrollStopEpsilon() override; virtual void remedyLayoutParameter(Widget* item)override; virtual void moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack) override; diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index f4d7220678..dc08b5726f 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -502,6 +502,11 @@ bool ScrollView::isNecessaryAutoScrollBrake() return false; } +float ScrollView::getAutoScrollStopEpsilon() +{ + return FLT_EPSILON; +} + void ScrollView::processAutoScrolling(float deltaTime) { // Make auto scroll shorter if it needs to deaccelerate. @@ -520,7 +525,7 @@ void ScrollView::processAutoScrolling(float deltaTime) // Calculate the new position Vec2 newPosition = _autoScrollStartPosition + (_autoScrollTargetDelta * percentage); - bool reachedEnd = (percentage == 1); + bool reachedEnd = fabs(percentage - 1) <= this->getAutoScrollStopEpsilon(); if(_bounceEnabled) { diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 83d67e9670..986800dab7 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -624,6 +624,7 @@ protected: void updateScrollBar(const Vec2& outOfBoundary); protected: + virtual float getAutoScrollStopEpsilon(); Layout* _innerContainer; Direction _direction;