| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/app_list/pagination_model.h" | 5 #include "ui/app_list/pagination_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/app_list/pagination_model_observer.h" | 9 #include "ui/app_list/pagination_model_observer.h" |
| 10 #include "ui/base/animation/slide_animation.h" | 10 #include "ui/base/animation/slide_animation.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 if (selected_page_ >= total_pages_) | 34 if (selected_page_ >= total_pages_) |
| 35 SelectPage(total_pages_ - 1, false /* animate */); | 35 SelectPage(total_pages_ - 1, false /* animate */); |
| 36 FOR_EACH_OBSERVER(PaginationModelObserver, observers_, TotalPagesChanged()); | 36 FOR_EACH_OBSERVER(PaginationModelObserver, observers_, TotalPagesChanged()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void PaginationModel::SelectPage(int page, bool animate) { | 39 void PaginationModel::SelectPage(int page, bool animate) { |
| 40 if (animate) { | 40 if (animate) { |
| 41 // -1 and |total_pages_| are valid target page for animation. | 41 // -1 and |total_pages_| are valid target page for animation. |
| 42 DCHECK(page >= -1 && page <= total_pages_); | 42 DCHECK(page >= -1 && page <= total_pages_); |
| 43 | 43 |
| 44 if (!transition_animation_.get()) { | 44 if (!transition_animation_) { |
| 45 if (page == selected_page_) | 45 if (page == selected_page_) |
| 46 return; | 46 return; |
| 47 | 47 |
| 48 // Suppress over scroll animation if the same one happens too fast. | 48 // Suppress over scroll animation if the same one happens too fast. |
| 49 if (!is_valid_page(page)) { | 49 if (!is_valid_page(page)) { |
| 50 const base::TimeTicks now = base::TimeTicks::Now(); | 50 const base::TimeTicks now = base::TimeTicks::Now(); |
| 51 | 51 |
| 52 if (page == last_overscroll_target_page_) { | 52 if (page == last_overscroll_target_page_) { |
| 53 const int kMinOverScrollTimeGapInMs = 500; | 53 const int kMinOverScrollTimeGapInMs = 500; |
| 54 const base::TimeDelta time_elapsed = | 54 const base::TimeDelta time_elapsed = |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } else if (transition_animation_->GetCurrentValue() == 0) { | 258 } else if (transition_animation_->GetCurrentValue() == 0) { |
| 259 // Hiding animation ends. No page change should happen. | 259 // Hiding animation ends. No page change should happen. |
| 260 ResetTransitionAnimation(); | 260 ResetTransitionAnimation(); |
| 261 } | 261 } |
| 262 | 262 |
| 263 if (next_target >= 0) | 263 if (next_target >= 0) |
| 264 SelectPage(next_target, true); | 264 SelectPage(next_target, true); |
| 265 } | 265 } |
| 266 | 266 |
| 267 } // namespace app_list | 267 } // namespace app_list |
| OLD | NEW |