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

Side by Side Diff: chrome/browser/resources/ntp4/page_list_view.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 PageListView implementation. 6 * @fileoverview PageListView implementation.
7 * PageListView manages page list, dot list, switcher buttons and handles apps 7 * PageListView manages page list, dot list, switcher buttons and handles apps
8 * pages callbacks from backend. 8 * pages callbacks from backend.
9 * 9 *
10 * Note that you need to have AppLauncherHandler in your WebUI to use this code. 10 * Note that you need to have AppLauncherHandler in your WebUI to use this code.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // No apps page. 162 // No apps page.
163 if (this.shownPage == templateData['apps_page_id']) { 163 if (this.shownPage == templateData['apps_page_id']) {
164 this.shownPage = templateData['most_visited_page_id']; 164 this.shownPage = templateData['most_visited_page_id'];
165 this.shownPageIndex = 0; 165 this.shownPageIndex = 0;
166 } 166 }
167 167
168 document.body.classList.add('bare-minimum'); 168 document.body.classList.add('bare-minimum');
169 } 169 }
170 170
171 document.addEventListener('keydown', this.onDocKeyDown_.bind(this)); 171 document.addEventListener('keydown', this.onDocKeyDown_.bind(this));
172 // Prevent touch events from triggering any sort of native scrolling 172 // Prevent touch events from triggering any sort of native scrolling.
173 document.addEventListener('touchmove', function(e) { 173 document.addEventListener('touchmove', function(e) {
174 e.preventDefault(); 174 e.preventDefault();
175 }, true); 175 }, true);
176 176
177 this.tilePages = this.pageList.getElementsByClassName('tile-page'); 177 this.tilePages = this.pageList.getElementsByClassName('tile-page');
178 this.appsPages = this.pageList.getElementsByClassName('apps-page'); 178 this.appsPages = this.pageList.getElementsByClassName('apps-page');
179 179
180 // Initialize the cardSlider without any cards at the moment 180 // Initialize the cardSlider without any cards at the moment.
181 this.sliderFrame = cardSliderFrame; 181 this.sliderFrame = cardSliderFrame;
182 this.cardSlider = new cr.ui.CardSlider(this.sliderFrame, this.pageList, 182 this.cardSlider = new cr.ui.CardSlider(this.sliderFrame, this.pageList,
183 this.sliderFrame.offsetWidth); 183 this.sliderFrame.offsetWidth);
184 this.cardSlider.initialize(); 184
185 // Handle mousewheel events anywhere in the card slider, so that wheel
186 // events on the page switchers will still scroll the page.
187 // This listener must be added before the card slider is initialized,
188 // because it needs to be called before the card slider's handler.
189 var cardSlider = this.cardSlider;
190 cardSliderFrame.addEventListener('mousewheel', function(e) {
191 if (cardSlider.currentCardValue.handleMouseWheel(e)) {
192 e.preventDefault(); // Prevent default scroll behavior.
193 e.stopImmediatePropagation(); // Prevent horizontal card flipping.
194 }
195 });
196
197 this.cardSlider.initialize(
198 templateData.isSwipeTrackingFromScrollEventsEnabled);
185 199
186 // Handle events from the card slider. 200 // Handle events from the card slider.
187 this.pageList.addEventListener('cardSlider:card_changed', 201 this.pageList.addEventListener('cardSlider:card_changed',
188 this.onCardChanged_.bind(this)); 202 this.onCardChanged_.bind(this));
189 this.pageList.addEventListener('cardSlider:card_added', 203 this.pageList.addEventListener('cardSlider:card_added',
190 this.onCardAdded_.bind(this)); 204 this.onCardAdded_.bind(this));
191 this.pageList.addEventListener('cardSlider:card_removed', 205 this.pageList.addEventListener('cardSlider:card_removed',
192 this.onCardRemoved_.bind(this)); 206 this.onCardRemoved_.bind(this));
193 207
194 // Ensure the slider is resized appropriately with the window 208 // Ensure the slider is resized appropriately with the window.
195 window.addEventListener('resize', this.onWindowResize_.bind(this)); 209 window.addEventListener('resize', this.onWindowResize_.bind(this));
196 210
197 // Update apps when online state changes. 211 // Update apps when online state changes.
198 window.addEventListener('online', 212 window.addEventListener('online',
199 this.updateOfflineEnabledApps_.bind(this)); 213 this.updateOfflineEnabledApps_.bind(this));
200 window.addEventListener('offline', 214 window.addEventListener('offline',
201 this.updateOfflineEnabledApps_.bind(this)); 215 this.updateOfflineEnabledApps_.bind(this));
202 }, 216 },
203 217
204 /** 218 /**
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 if (page.navigationDot) 735 if (page.navigationDot)
722 page.navigationDot.remove(opt_animate); 736 page.navigationDot.remove(opt_animate);
723 this.cardSlider.removeCard(page); 737 this.cardSlider.removeCard(page);
724 }, 738 },
725 }; 739 };
726 740
727 return { 741 return {
728 PageListView: PageListView 742 PageListView: PageListView
729 }; 743 };
730 }); 744 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698