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

Side by Side Diff: chrome/browser/resources/ntp4/page_switcher.js

Issue 9116037: [NTP4] Make TilePage and CardSlider evented to simplify code and fix page switcher bug (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: found one more bug when you leave a tab while mousing over page switcher Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 /** 5 /**
6 * @fileoverview Page switcher 6 * @fileoverview Page switcher
7 * This is the class for the left and right navigation arrows that switch 7 * This is the class for the left and right navigation arrows that switch
8 * between pages. 8 * between pages.
9 */ 9 */
10 cr.define('ntp4', function() { 10 cr.define('ntp4', function() {
(...skipping 14 matching lines...) Expand all
25 25
26 el.dragWrapper_ = new cr.ui.DragWrapper(el, el); 26 el.dragWrapper_ = new cr.ui.DragWrapper(el, el);
27 }, 27 },
28 28
29 /** 29 /**
30 * Activate the switcher (go to the next card). 30 * Activate the switcher (go to the next card).
31 * @private 31 * @private
32 */ 32 */
33 activate_: function() { 33 activate_: function() {
34 var cardSlider = ntp4.getCardSlider(); 34 var cardSlider = ntp4.getCardSlider();
35 cardSlider.selectCard(cardSlider.currentCard + this.direction_, true); 35 var index = cardSlider.currentCard + this.direction_;
36 var numCards = cardSlider.cardCount - 1;
37 cardSlider.selectCard(Math.max(0, Math.min(index, numCards)), true);
36 }, 38 },
37 39
38 /** 40 /**
39 * Handler for the mousewheel event on a pager. We pass through the scroll 41 * Handler for the mousewheel event on a pager. We pass through the scroll
40 * to the page. This is necssary because the page is our sibling in the DOM 42 * to the page. This is necssary because the page is our sibling in the DOM
41 * hierarchy, so the event won't naturally pass through to it. 43 * hierarchy, so the event won't naturally pass through to it.
42 * @param {Event} e The mousewheel event. 44 * @param {Event} e The mousewheel event.
43 * @private 45 * @private
44 */ 46 */
45 onMouseWheel_: function(e) { 47 onMouseWheel_: function(e) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 this.dragNavTimeout_ = null; 111 this.dragNavTimeout_ = null;
110 } 112 }
111 }, 113 },
112 114
113 }; 115 };
114 116
115 return { 117 return {
116 initializePageSwitcher: PageSwitcher.template.decorate 118 initializePageSwitcher: PageSwitcher.template.decorate
117 } 119 }
118 }); 120 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/page_list_view.js ('k') | chrome/browser/resources/ntp4/tile_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698