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

Side by Side Diff: chrome/browser/resources/ntp4/tile_page.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 cr.define('ntp', function() { 5 cr.define('ntp', function() {
6 'use strict'; 6 'use strict';
7 7
8 // We can't pass the currently dragging tile via dataTransfer because of 8 // We can't pass the currently dragging tile via dataTransfer because of
9 // http://crbug.com/31037 9 // http://crbug.com/31037
10 var currentlyDraggingTile = null; 10 var currentlyDraggingTile = null;
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // These are properties used in updateTopMargin. 441 // These are properties used in updateTopMargin.
442 this.animatedTopMarginPx_ = 0; 442 this.animatedTopMarginPx_ = 0;
443 this.topMarginPx_ = 0; 443 this.topMarginPx_ = 0;
444 444
445 this.eventTracker = new EventTracker(); 445 this.eventTracker = new EventTracker();
446 this.eventTracker.add(window, 'resize', this.onResize_.bind(this)); 446 this.eventTracker.add(window, 'resize', this.onResize_.bind(this));
447 447
448 this.addEventListener('DOMNodeInsertedIntoDocument', 448 this.addEventListener('DOMNodeInsertedIntoDocument',
449 this.onNodeInsertedIntoDocument_); 449 this.onNodeInsertedIntoDocument_);
450 450
451 this.addEventListener('mousewheel', this.onMouseWheel_);
452 this.content_.addEventListener('scroll', this.onScroll_.bind(this)); 451 this.content_.addEventListener('scroll', this.onScroll_.bind(this));
453 452
454 this.dragWrapper_ = new cr.ui.DragWrapper(this.tileGrid_, this); 453 this.dragWrapper_ = new cr.ui.DragWrapper(this.tileGrid_, this);
455 454
456 this.addEventListener('cardselected', this.handleCardSelection_); 455 this.addEventListener('cardselected', this.handleCardSelection_);
457 this.addEventListener('carddeselected', this.handleCardDeselection_); 456 this.addEventListener('carddeselected', this.handleCardDeselection_);
458 this.addEventListener('focus', this.handleFocus_); 457 this.addEventListener('focus', this.handleFocus_);
459 this.addEventListener('keydown', this.handleKeyDown_); 458 this.addEventListener('keydown', this.handleKeyDown_);
460 this.addEventListener('mousedown', this.handleMouseDown_); 459 this.addEventListener('mousedown', this.handleMouseDown_);
461 460
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 * Places an element at the bottom of the content div. Used in bare-minimum 1045 * Places an element at the bottom of the content div. Used in bare-minimum
1047 * mode to hold #footer. 1046 * mode to hold #footer.
1048 * @param {HTMLElement} footerNode The node to append to content. 1047 * @param {HTMLElement} footerNode The node to append to content.
1049 */ 1048 */
1050 appendFooter: function(footerNode) { 1049 appendFooter: function(footerNode) {
1051 this.footerNode_ = footerNode; 1050 this.footerNode_ = footerNode;
1052 this.content_.appendChild(footerNode); 1051 this.content_.appendChild(footerNode);
1053 }, 1052 },
1054 1053
1055 /** 1054 /**
1056 * Scrolls the page in response to a mousewheel event. 1055 * Scrolls the page in response to an mousewheel event, although the event
1056 * may have been triggered on a different element. Return true if the
1057 * event triggered scrolling, and false otherwise.
1058 * This is called explicitly, which allows a consistent experience whether
1059 * the user scrolls on the page or on the page switcher, because this
1060 * function provides a common conversion factor between wheel delta and
1061 * scroll delta.
1057 * @param {Event} e The mousewheel event. 1062 * @param {Event} e The mousewheel event.
1058 */ 1063 */
1059 handleMouseWheel: function(e) { 1064 handleMouseWheel: function(e) {
1065 if (e.wheelDeltaY == 0)
1066 return false;
1067
1060 this.content_.scrollTop -= e.wheelDeltaY / 3; 1068 this.content_.scrollTop -= e.wheelDeltaY / 3;
1069 return true;
1061 }, 1070 },
1062 1071
1063 /** 1072 /**
1064 * Handles mouse wheels on |this|. We handle this explicitly because we want
1065 * a consistent experience whether the user scrolls on the page or on the
1066 * page switcher (handleMouseWheel provides a common conversion factor
1067 * between wheel delta and scroll delta).
1068 * @param {Event} e The mousewheel event.
1069 * @private
1070 */
1071 onMouseWheel_: function(e) {
1072 if (e.wheelDeltaY == 0)
1073 return;
1074
1075 this.handleMouseWheel(e);
1076 e.preventDefault();
1077 e.stopPropagation();
1078 },
1079
1080 /**
1081 * Handler for the 'scroll' event on |content_|. 1073 * Handler for the 'scroll' event on |content_|.
1082 * @param {Event} e The scroll event. 1074 * @param {Event} e The scroll event.
1083 * @private 1075 * @private
1084 */ 1076 */
1085 onScroll_: function(e) { 1077 onScroll_: function(e) {
1086 this.queueUpdateScrollbars_(); 1078 this.queueUpdateScrollbars_();
1087 }, 1079 },
1088 1080
1089 /** 1081 /**
1090 * ID of scrollbar update timer. If 0, there's no scrollbar re-calc queued. 1082 * ID of scrollbar update timer. If 0, there's no scrollbar re-calc queued.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 assert(false); 1325 assert(false);
1334 }, 1326 },
1335 }; 1327 };
1336 1328
1337 return { 1329 return {
1338 getCurrentlyDraggingTile: getCurrentlyDraggingTile, 1330 getCurrentlyDraggingTile: getCurrentlyDraggingTile,
1339 setCurrentDropEffect: setCurrentDropEffect, 1331 setCurrentDropEffect: setCurrentDropEffect,
1340 TilePage: TilePage, 1332 TilePage: TilePage,
1341 }; 1333 };
1342 }); 1334 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/page_switcher.js ('k') | chrome/browser/resources/shared/js/cr/ui/card_slider.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698