OLD | NEW |
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 Loading... |
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 Loading... |
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 }); |
OLD | NEW |