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

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 scrolling when over page switcher. 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_);
Patrick Dubroy 2012/04/17 17:28:24 We don't need to add a listener to this object, be
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.
1057 * This is called explicitly, which allows a consistent experience whether
1058 * the user scrolls on the page or on the page switcher, because this
1059 * function provides a common conversion factor between wheel delta and
1060 * scroll delta.
1057 * @param {Event} e The mousewheel event. 1061 * @param {Event} e The mousewheel event.
1058 */ 1062 */
1059 handleMouseWheel: function(e) { 1063 handleMouseWheel: function(e) {
1064 if (e.wheelDeltaY == 0)
1065 return;
1066
1060 this.content_.scrollTop -= e.wheelDeltaY / 3; 1067 this.content_.scrollTop -= e.wheelDeltaY / 3;
1068
1069 // Prevent the event from triggering the default scroll behavior on this
1070 // element.
1071 for (var el = e.target; el; el = el.parentNode) {
1072 if (el == this) {
1073 e.preventDefault();
1074 break;
1075 }
1076 }
1061 }, 1077 },
1062 1078
1063 /** 1079 /**
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_|. 1080 * Handler for the 'scroll' event on |content_|.
1082 * @param {Event} e The scroll event. 1081 * @param {Event} e The scroll event.
1083 * @private 1082 * @private
1084 */ 1083 */
1085 onScroll_: function(e) { 1084 onScroll_: function(e) {
1086 this.queueUpdateScrollbars_(); 1085 this.queueUpdateScrollbars_();
1087 }, 1086 },
1088 1087
1089 /** 1088 /**
1090 * ID of scrollbar update timer. If 0, there's no scrollbar re-calc queued. 1089 * 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); 1332 assert(false);
1334 }, 1333 },
1335 }; 1334 };
1336 1335
1337 return { 1336 return {
1338 getCurrentlyDraggingTile: getCurrentlyDraggingTile, 1337 getCurrentlyDraggingTile: getCurrentlyDraggingTile,
1339 setCurrentDropEffect: setCurrentDropEffect, 1338 setCurrentDropEffect: setCurrentDropEffect,
1340 TilePage: TilePage, 1339 TilePage: TilePage,
1341 }; 1340 };
1342 }); 1341 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698