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

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

Issue 10388134: [NTP4] Fix appmarklet animation drop bug. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: estade review / behavior change Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/ntp4/page_list_view.js ('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) 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 * instance is removed from the DOM. 551 * instance is removed from the DOM.
552 * @private 552 * @private
553 */ 553 */
554 tearDown_: function() { 554 tearDown_: function() {
555 this.eventTracker.removeAll(); 555 this.eventTracker.removeAll();
556 }, 556 },
557 557
558 /** 558 /**
559 * Appends a tile to the end of the tile grid. 559 * Appends a tile to the end of the tile grid.
560 * @param {HTMLElement} tileElement The contents of the tile. 560 * @param {HTMLElement} tileElement The contents of the tile.
561 * @param {?boolean} animate If true, the append will be animated. 561 * @param {boolean} animate If true, the append will be animated.
562 * @protected 562 * @protected
563 */ 563 */
564 appendTile: function(tileElement, animate) { 564 appendTile: function(tileElement, animate) {
565 this.addTileAt(tileElement, this.tileElements_.length, animate); 565 this.addTileAt(tileElement, this.tileElements_.length, animate);
566 }, 566 },
567 567
568 /** 568 /**
569 * Adds the given element to the tile grid. 569 * Adds the given element to the tile grid.
570 * @param {Node} tileElement The tile object/node to insert. 570 * @param {Node} tileElement The tile object/node to insert.
571 * @param {number} index The location in the tile grid to insert it at. 571 * @param {number} index The location in the tile grid to insert it at.
572 * @param {boolean=} opt_animate If true, the tile in question will be 572 * @param {boolean} animate If true, the tile in question will be
573 * animated (other tiles, if they must reposition, do not animate). 573 * animated (other tiles, if they must reposition, do not animate).
574 * @protected 574 * @protected
575 */ 575 */
576 addTileAt: function(tileElement, index, opt_animate) { 576 addTileAt: function(tileElement, index, animate) {
577 this.classList.remove('animating-tile-page'); 577 this.classList.remove('animating-tile-page');
578 if (opt_animate) 578 if (animate)
579 tileElement.classList.add('new-tile-contents'); 579 tileElement.classList.add('new-tile-contents');
580 580
581 // Make sure the index is positive and either in the the bounds of 581 // Make sure the index is positive and either in the the bounds of
582 // this.tileElements_ or at the end (meaning append). 582 // this.tileElements_ or at the end (meaning append).
583 assert(index >= 0 && index <= this.tileElements_.length); 583 assert(index >= 0 && index <= this.tileElements_.length);
584 584
585 var wrapperDiv = new Tile(tileElement); 585 var wrapperDiv = new Tile(tileElement);
586 // If is out of the bounds of the tile element list, .insertBefore() will 586 // If is out of the bounds of the tile element list, .insertBefore() will
587 // act just like appendChild(). 587 // act just like appendChild().
588 this.tileGrid_.insertBefore(wrapperDiv, this.tileElements_[index]); 588 this.tileGrid_.insertBefore(wrapperDiv, this.tileElements_[index]);
589 this.calculateLayoutValues_(); 589 this.calculateLayoutValues_();
590 this.heightChanged_(); 590 this.heightChanged_();
591 591
592 this.repositionTiles_(); 592 this.repositionTiles_();
593 this.fireAddedEvent(wrapperDiv, index, !!opt_animate); 593 this.fireAddedEvent(wrapperDiv, index, animate);
594 }, 594 },
595 595
596 /** 596 /**
597 * Notify interested subscribers that a tile has been removed from this 597 * Notify interested subscribers that a tile has been removed from this
598 * page. 598 * page.
599 * @param {Tile} tile The newly added tile. 599 * @param {Tile} tile The newly added tile.
600 * @param {number} index The index of the tile that was added. 600 * @param {number} index The index of the tile that was added.
601 * @param {boolean} wasAnimated Whether the removal was animated. 601 * @param {boolean} wasAnimated Whether the removal was animated.
602 */ 602 */
603 fireAddedEvent: function(tile, index, wasAnimated) { 603 fireAddedEvent: function(tile, index, wasAnimated) {
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 */ 1163 */
1164 doDragLeave: function(e) { 1164 doDragLeave: function(e) {
1165 this.cleanupDrag(); 1165 this.cleanupDrag();
1166 }, 1166 },
1167 1167
1168 /** 1168 /**
1169 * Performs all actions necessary when a drag enters the tile page. 1169 * Performs all actions necessary when a drag enters the tile page.
1170 * @param {Event} e A mouseover event for the drag enter. 1170 * @param {Event} e A mouseover event for the drag enter.
1171 */ 1171 */
1172 doDragEnter: function(e) { 1172 doDragEnter: function(e) {
1173
1174 // Applies the mask so doppleganger tiles disappear into the fog. 1173 // Applies the mask so doppleganger tiles disappear into the fog.
1175 this.updateMask_(); 1174 this.updateMask_();
1176 1175
1177 this.classList.add('animating-tile-page'); 1176 this.classList.add('animating-tile-page');
1178 this.withinPageDrag_ = this.contains(currentlyDraggingTile); 1177 this.withinPageDrag_ = this.contains(currentlyDraggingTile);
1179 this.dragItemIndex_ = this.withinPageDrag_ ? 1178 this.dragItemIndex_ = this.withinPageDrag_ ?
1180 currentlyDraggingTile.index : this.tileElements_.length; 1179 currentlyDraggingTile.index : this.tileElements_.length;
1181 this.currentDropIndex_ = this.dragItemIndex_; 1180 this.currentDropIndex_ = this.dragItemIndex_;
1182 1181
1183 // The new tile may change the number of rows, hence the top margin 1182 // The new tile may change the number of rows, hence the top margin
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 assert(false); 1337 assert(false);
1339 }, 1338 },
1340 }; 1339 };
1341 1340
1342 return { 1341 return {
1343 getCurrentlyDraggingTile: getCurrentlyDraggingTile, 1342 getCurrentlyDraggingTile: getCurrentlyDraggingTile,
1344 setCurrentDropEffect: setCurrentDropEffect, 1343 setCurrentDropEffect: setCurrentDropEffect,
1345 TilePage: TilePage, 1344 TilePage: TilePage,
1346 }; 1345 };
1347 }); 1346 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/page_list_view.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698