diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-01 04:07:09 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-01 04:07:09 +0000 |
commit | c63520dc04191844c17bae842e68f5f2b1ad4995 (patch) | |
tree | b92630c6eef4eb7118e7ab4a9fe68bf74e53e88e /ui/app_list/pagination_model.cc | |
parent | fea761fceec8090fef4c812cd2f0d5ee48b7fe1c (diff) | |
download | chromium_src-c63520dc04191844c17bae842e68f5f2b1ad4995.zip chromium_src-c63520dc04191844c17bae842e68f5f2b1ad4995.tar.gz chromium_src-c63520dc04191844c17bae842e68f5f2b1ad4995.tar.bz2 |
app_list: Suppress repeated over scroll animations.
Scroll event might create a bunch of over scroll animations. Suppress
that to only one every 500ms.
Also stop propagation for handled scroll event because the handled
flag gets reset during bubbling up and the same event is then translated
to mouse wheel event and send back to us again.
BUG=178824
TEST=No excessive over scroll animation with touchpad.
R=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/12387027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185457 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/app_list/pagination_model.cc')
-rw-r--r-- | ui/app_list/pagination_model.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ui/app_list/pagination_model.cc b/ui/app_list/pagination_model.cc index bdcc084..fcd1d46 100644 --- a/ui/app_list/pagination_model.cc +++ b/ui/app_list/pagination_model.cc @@ -17,7 +17,8 @@ PaginationModel::PaginationModel() transition_(-1, 0), pending_selected_page_(-1), transition_duration_ms_(0), - overscroll_transition_duration_ms_(0) { + overscroll_transition_duration_ms_(0), + last_overscroll_target_page_(0) { } PaginationModel::~PaginationModel() { @@ -44,6 +45,22 @@ void PaginationModel::SelectPage(int page, bool animate) { if (page == selected_page_) return; + // Suppress over scroll animation if the same one happens too fast. + if (!is_valid_page(page)) { + const base::TimeTicks now = base::TimeTicks::Now(); + + if (page == last_overscroll_target_page_) { + const int kMinOverScrollTimeGapInMs = 500; + const base::TimeDelta time_elapsed = + now - last_overscroll_animation_start_time_; + if (time_elapsed.InMilliseconds() < kMinOverScrollTimeGapInMs) + return; + } + + last_overscroll_target_page_ = page; + last_overscroll_animation_start_time_ = now; + } + // Creates an animation if there is not one. StartTransitionAnimation(Transition(page, 0)); return; |