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

Side by Side Diff: chrome/browser/resources/ntp4/tile_page.js

Issue 8771060: ntp: adjust top padding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more commentary Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/ntp4/tile_page.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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('ntp4', function() { 5 cr.define('ntp4', 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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 890
891 updateTopMargin_: function() { 891 updateTopMargin_: function() {
892 var layout = this.layoutValues_; 892 var layout = this.layoutValues_;
893 893
894 // The top margin is set so that the vertical midpoint of the grid will 894 // The top margin is set so that the vertical midpoint of the grid will
895 // be 1/3 down the page. 895 // be 1/3 down the page.
896 var numTiles = this.tileCount + 896 var numTiles = this.tileCount +
897 (this.isCurrentDragTarget && !this.withinPageDrag_ ? 1 : 0); 897 (this.isCurrentDragTarget && !this.withinPageDrag_ ? 1 : 0);
898 var numRows = Math.ceil(numTiles / layout.numRowTiles); 898 var numRows = Math.ceil(numTiles / layout.numRowTiles);
899 var usedHeight = layout.rowHeight * numRows; 899 var usedHeight = layout.rowHeight * numRows;
900 // 100 matches the top padding of tile-page. 900 // 60 matches the top padding of tile-page (which acts as the minimum).
901 var newMargin = document.documentElement.clientHeight / 3 - 901 var newMargin = document.documentElement.clientHeight / 3 -
902 usedHeight / 2 - 100 - this.content_.offsetTop; 902 usedHeight / 3 - 60;
903 newMargin = Math.max(newMargin, 0); 903 newMargin = Math.max(newMargin, 0);
904 904
905 // |newMargin| is the final margin we actually want to show. However, 905 // |newMargin| is the final margin we actually want to show. However,
906 // part of that should be animated and part should not (for the same 906 // part of that should be animated and part should not (for the same
907 // reason as with leftMargin). The approach is to consider differences 907 // reason as with leftMargin). The approach is to consider differences
908 // when the layout changes from wide to narrow or vice versa as 908 // when the layout changes from wide to narrow or vice versa as
909 // 'animatable'. These differences accumulate in animatedTopMarginPx_, 909 // 'animatable'. These differences accumulate in animatedTopMarginPx_,
910 // while topMarginPx_ caches the real (total) margin. Either of these 910 // while topMarginPx_ caches the real (total) margin. Either of these
911 // calculations may come out to be negative, so we use margins as the 911 // calculations may come out to be negative, so we use margins as the
912 // css property. 912 // css property.
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 assert(false); 1230 assert(false);
1231 }, 1231 },
1232 }; 1232 };
1233 1233
1234 return { 1234 return {
1235 getCurrentlyDraggingTile: getCurrentlyDraggingTile, 1235 getCurrentlyDraggingTile: getCurrentlyDraggingTile,
1236 setCurrentDropEffect: setCurrentDropEffect, 1236 setCurrentDropEffect: setCurrentDropEffect,
1237 TilePage: TilePage, 1237 TilePage: TilePage,
1238 }; 1238 };
1239 }); 1239 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/tile_page.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698