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

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

Issue 10092017: Mac: Prevent NTP mousewheel events from being suppressed on Lion. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix grammar & style. Created 8 years, 8 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
OLDNEW
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 /** 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('ntp', function() { 10 cr.define('ntp', function() {
11 11
12 function PageSwitcher() { 12 function PageSwitcher() {
13 } 13 }
14 14
15 PageSwitcher.template = { 15 PageSwitcher.template = {
16 __proto__: HTMLButtonElement.prototype, 16 __proto__: HTMLButtonElement.prototype,
17 17
18 decorate: function(el) { 18 decorate: function(el) {
19 el.__proto__ = PageSwitcher.template; 19 el.__proto__ = PageSwitcher.template;
20 20
21 el.addEventListener('click', el.activate_); 21 el.addEventListener('click', el.activate_);
22 el.addEventListener('mousewheel', el.onMouseWheel_);
23 22
24 el.direction_ = el.id == 'page-switcher-start' ? -1 : 1; 23 el.direction_ = el.id == 'page-switcher-start' ? -1 : 1;
25 24
26 el.dragWrapper_ = new cr.ui.DragWrapper(el, el); 25 el.dragWrapper_ = new cr.ui.DragWrapper(el, el);
27 }, 26 },
28 27
29 /** 28 /**
30 * Activate the switcher (go to the next card). 29 * Activate the switcher (go to the next card).
31 * @private 30 * @private
32 */ 31 */
33 activate_: function() { 32 activate_: function() {
34 var cardSlider = ntp.getCardSlider(); 33 var cardSlider = ntp.getCardSlider();
35 var index = cardSlider.currentCard + this.direction_; 34 var index = cardSlider.currentCard + this.direction_;
36 var numCards = cardSlider.cardCount - 1; 35 var numCards = cardSlider.cardCount - 1;
37 cardSlider.selectCard(Math.max(0, Math.min(index, numCards)), true); 36 cardSlider.selectCard(Math.max(0, Math.min(index, numCards)), true);
38 }, 37 },
39 38
40 /**
41 * Handler for the mousewheel event on a pager. We pass through the scroll
42 * to the page. This is necssary because the page is our sibling in the DOM
43 * hierarchy, so the event won't naturally pass through to it.
44 * @param {Event} e The mousewheel event.
45 * @private
46 */
47 onMouseWheel_: function(e) {
48 var page = ntp.getCardSlider().currentCardValue;
49 page.handleMouseWheel(e);
50 },
51
52 shouldAcceptDrag: function(e) { 39 shouldAcceptDrag: function(e) {
53 // We allow all drags to trigger the page switching effect. 40 // We allow all drags to trigger the page switching effect.
54 return true; 41 return true;
55 }, 42 },
56 43
57 doDragEnter: function(e) { 44 doDragEnter: function(e) {
58 this.scheduleDelayedSwitch_(); 45 this.scheduleDelayedSwitch_();
59 this.doDragOver(e); 46 this.doDragOver(e);
60 }, 47 },
61 48
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 this.dragNavTimeout_ = null; 98 this.dragNavTimeout_ = null;
112 } 99 }
113 }, 100 },
114 101
115 }; 102 };
116 103
117 return { 104 return {
118 initializePageSwitcher: PageSwitcher.template.decorate 105 initializePageSwitcher: PageSwitcher.template.decorate
119 }; 106 };
120 }); 107 });
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