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

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

Issue 10689164: [NTP4] Remove promo text horizontal transitions on NTP opening. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bug Created 8 years, 5 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 | « chrome/browser/resources/ntp4/new_tab.css ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/tile_page.js
diff --git a/chrome/browser/resources/ntp4/tile_page.js b/chrome/browser/resources/ntp4/tile_page.js
index 33baa7fcde435379154c8c7a5f3782cd67e42315..924600e3bf2a45a23914cfbc594aec9e53e85cb3 100644
--- a/chrome/browser/resources/ntp4/tile_page.js
+++ b/chrome/browser/resources/ntp4/tile_page.js
@@ -819,9 +819,10 @@ cr.define('ntp', function() {
realTileValues.interTileSpacing;
this.layoutValues_ = {
- numRowTiles: numRowTiles,
- leftMargin: leftMargin,
colWidth: realTileValues.offsetX,
+ gridWidth: effectiveGridWidth,
+ leftMargin: leftMargin,
+ numRowTiles: numRowTiles,
rowHeight: rowHeight,
tileWidth: realTileValues.tileWidth,
wide: wide,
@@ -842,6 +843,18 @@ cr.define('ntp', function() {
},
/**
+ * @return {number} The amount of margin that should be animated (in pixels)
+ * for the current grid layout.
+ */
+ getAnimatedLeftMargin_: function() {
+ if (this.layoutValues_.wide)
+ return 0;
+
+ var grid = this.gridValues_;
+ return (grid.minWideWidth - MIN_WIDE_MARGIN - grid.narrowWidth) / 2;
+ },
+
+ /**
* Calculates the x/y coordinates for an element and moves it there.
* @param {number} index The index of the element to be positioned.
* @param {number} indexOffset If provided, this is added to |index| when
@@ -866,8 +879,7 @@ cr.define('ntp', function() {
var animatedTileValues = layout.wide ?
grid.wideTileValues : grid.narrowTileValues;
// Animate the difference between three-wide and six-wide.
- var animatedLeftMargin = layout.wide ?
- 0 : (grid.minWideWidth - MIN_WIDE_MARGIN - grid.narrowWidth) / 2;
+ var animatedLeftMargin = this.getAnimatedLeftMargin_();
var animatedX = col * animatedTileValues.offsetX + animatedLeftMargin;
var animatedY = row * (this.heightForWidth(animatedTileValues.tileWidth) +
animatedTileValues.interTileSpacing);
@@ -1021,11 +1033,29 @@ cr.define('ntp', function() {
* Position the notification if there's one showing.
*/
positionNotification_: function() {
- if (this.notification && !this.notification.hidden) {
- this.notification.style.margin =
- -this.notification.offsetHeight + 'px ' +
- this.layoutValues_.leftMargin + 'px 0';
- }
+ var notification = this.notification;
+ if (!notification || notification.hidden)
+ return;
+
+ // Update the horizontal position.
+ var animatedLeftMargin = this.getAnimatedLeftMargin_();
+ notification.style.WebkitMarginStart = animatedLeftMargin + 'px';
+ var leftOffset = (this.layoutValues_.leftMargin - animatedLeftMargin) *
+ (isRTL() ? -1 : 1);
+ notification.style.WebkitTransform = 'translateX(' + leftOffset + 'px)';
+
+ // Update the allowable widths of the text.
+ var buttonWidth = notification.querySelector('button').offsetWidth + 8;
+ notification.querySelector('span').style.maxWidth =
+ this.layoutValues_.gridWidth - buttonWidth + 'px';
+
+ // This makes sure the text doesn't condense smaller than the narrow size
+ // of the grid (e.g. when a user makes the window really small).
+ notification.style.minWidth =
+ this.gridValues_.narrowWidth - buttonWidth + 'px';
+
+ // Update the top position.
+ notification.style.marginTop = -notification.offsetHeight + 'px';
},
/**
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698