Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Unified Diff: ui/app_list/pagination_model.cc

Issue 316393002: App list uses PaginationModel to transition between pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed tests -- adds blank pages so we have 3 pages in the test environment. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/app_list/pagination_model.cc
diff --git a/ui/app_list/pagination_model.cc b/ui/app_list/pagination_model.cc
index 5e8d655a37580f5458b6b924b8fe09221412927d..c2bf8e5da741f16f16cb9cda23edce5c38ec6454 100644
--- a/ui/app_list/pagination_model.cc
+++ b/ui/app_list/pagination_model.cc
@@ -99,6 +99,10 @@ void PaginationModel::SelectPageRelative(int delta, bool animate) {
SelectPage(CalculateTargetPage(delta), animate);
}
+void PaginationModel::FinishAnimation() {
+ SelectPage(SelectedTargetPage(), false);
+}
+
void PaginationModel::SetTransition(const Transition& transition) {
// -1 and |total_pages_| is a valid target page, which means user is at
// the end and there is no target page for this scroll.
@@ -177,6 +181,20 @@ void PaginationModel::RemoveObserver(PaginationModelObserver* observer) {
observers_.RemoveObserver(observer);
}
+int PaginationModel::SelectedTargetPage() const {
+ // If no animation, or animation is in reverse, just the selected page.
+ if (!transition_animation_ || !transition_animation_->IsShowing())
+ return selected_page_;
+
+ // If, at the end of the current animation, we will animate to another page,
+ // return that eventual page.
+ if (pending_selected_page_ >= 0)
+ return pending_selected_page_;
+
+ // Just the target of the current animation.
+ return transition_.target_page;
+}
+
void PaginationModel::NotifySelectedPageChanged(int old_selected,
int new_selected) {
FOR_EACH_OBSERVER(PaginationModelObserver,
@@ -194,14 +212,7 @@ void PaginationModel::NotifyTransitionChanged() {
int PaginationModel::CalculateTargetPage(int delta) const {
DCHECK_GT(total_pages_, 0);
-
- int current_page = selected_page_;
- if (transition_animation_ && transition_animation_->IsShowing()) {
- current_page = pending_selected_page_ >= 0 ?
- pending_selected_page_ : transition_.target_page;
- }
-
- const int target_page = current_page + delta;
+ const int target_page = SelectedTargetPage() + delta;
int start_page = 0;
int end_page = total_pages_ - 1;

Powered by Google App Engine
This is Rietveld 408576698