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

Unified Diff: chrome/browser/resources/ntp4/card_slider.js

Issue 7647015: ntp4: Horizontal swipes should only trigger history on mac when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/card_slider.js
diff --git a/chrome/browser/resources/ntp4/card_slider.js b/chrome/browser/resources/ntp4/card_slider.js
index 0cd671119532bca94149892b8c09b87cd8354848..d6613a26a6c10f50186e31ed14839b11b3e8881a 100644
--- a/chrome/browser/resources/ntp4/card_slider.js
+++ b/chrome/browser/resources/ntp4/card_slider.js
@@ -221,7 +221,18 @@ var CardSlider = (function() {
if (e.wheelDeltaX == 0)
return;
- var scrollAmountPerPage = ntp4.isRTL() ? 120 : -120;
+ var preventDefault = true;
+ // If the horizontal scroll didn't change cards (on the far right of
+ // the NTP), let the browser take a shot at the event as well.
+ if (this.currentCard === 0 && this.mouseWheelScrollAmount_ > 0)
+ preventDefault = false;
+ if (this.currentCard === this.cards_.length - 1 &&
+ this.mouseWheelScrollAmount_ < 0)
Evan Stade 2011/08/19 22:35:40 curlies
Nico 2011/08/19 22:54:47 Done.
+ preventDefault = false;
+
+ var scrollAmountPerPage = cr.isMac ? 400 : 120;
Evan Stade 2011/08/19 22:35:40 it strikes me you should test this with a mouse wi
Nico 2011/08/19 22:54:47 I tested with a multitouch touch pad (feels good),
Evan Stade 2011/08/19 23:10:56 you could do something hacky like "if the scroll v
+ if (!ntp4.isRTL())
+ scrollAmountPerPage *= -1;
this.mouseWheelScrollAmount_ += e.wheelDeltaX;
if (Math.abs(this.mouseWheelScrollAmount_) >=
Math.abs(scrollAmountPerPage)) {
@@ -229,7 +240,7 @@ var CardSlider = (function() {
pagesToScroll =
(pagesToScroll > 0 ? Math.floor : Math.ceil)(pagesToScroll);
var newCardIndex = this.currentCard + pagesToScroll;
- newCardIndex = Math.min(this.cards_.length,
+ newCardIndex = Math.min(this.cards_.length - 1,
Math.max(0, newCardIndex));
this.selectCard(newCardIndex, true);
this.mouseWheelScrollAmount_ -= pagesToScroll * scrollAmountPerPage;
@@ -244,6 +255,9 @@ var CardSlider = (function() {
this.scrollClearTimeout_ =
setTimeout(this.clearMouseWheelScroll_.bind(this), 500);
}
+
+ if (preventDefault)
+ e.preventDefault();
},
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698