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

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

Issue 6992011: ntp4: fix one more small dragging glitch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 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 | « no previous file | 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 /** 8 /**
9 * Creates a new Tileobject. Tiles wrap content on a TilePage, providing 9 * Creates a new Tileobject. Tiles wrap content on a TilePage, providing
10 * some styling and drag functionality. 10 * some styling and drag functionality.
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 tile.setGridPosition(animatedX, animatedY); 440 tile.setGridPosition(animatedX, animatedY);
441 tile.firstChild.setBounds(layout.tileWidth, 441 tile.firstChild.setBounds(layout.tileWidth,
442 realX - animatedX, 442 realX - animatedX,
443 realY - animatedY); 443 realY - animatedY);
444 444
445 // This code calculates whether the tile needs to show a clone of itself 445 // This code calculates whether the tile needs to show a clone of itself
446 // wrapped around the other side of the tile grid. 446 // wrapped around the other side of the tile grid.
447 var offTheRight = col == layout.numRowTiles || 447 var offTheRight = col == layout.numRowTiles ||
448 (col == layout.numRowTiles - 1 && tile.hasDoppleganger()); 448 (col == layout.numRowTiles - 1 && tile.hasDoppleganger());
449 var offTheLeft = col == -1 || (col == 0 && tile.hasDoppleganger()); 449 var offTheLeft = col == -1 || (col == 0 && tile.hasDoppleganger());
450 if (this.dragEnters_ > 0 && (offTheRight || offTheLeft)) { 450 if (this.isCurrentDragTarget_ && (offTheRight || offTheLeft)) {
451 var sign = offTheRight ? 1 : -1; 451 var sign = offTheRight ? 1 : -1;
452 tile.showDoppleganger(-layout.numRowTiles * layout.colWidth * sign, 452 tile.showDoppleganger(-layout.numRowTiles * layout.colWidth * sign,
453 layout.rowHeight * sign); 453 layout.rowHeight * sign);
454 } else { 454 } else {
455 tile.clearDoppleganger(); 455 tile.clearDoppleganger();
456 } 456 }
457 }, 457 },
458 458
459 /** 459 /**
460 * Gets the index of the tile that should occupy coordinate (x, y). Note 460 * Gets the index of the tile that should occupy coordinate (x, y). Note
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 499 }
500 }, 500 },
501 501
502 /** 502 /**
503 * The tile grid has an image mask which fades at the edges. We only show 503 * The tile grid has an image mask which fades at the edges. We only show
504 * the mask when there is an active drag; it obscures doppleganger tiles 504 * the mask when there is an active drag; it obscures doppleganger tiles
505 * as they enter or exit the grid. 505 * as they enter or exit the grid.
506 * @private 506 * @private
507 */ 507 */
508 updateMask_: function() { 508 updateMask_: function() {
509 if (this.dragEnters_ == 0) { 509 if (!this.isCurrentDragTarget_) {
510 this.style.WebkitMaskBoxImage = ''; 510 this.style.WebkitMaskBoxImage = '';
511 return; 511 return;
512 } 512 }
513 513
514 var leftMargin = this.layoutValues_.leftMargin; 514 var leftMargin = this.layoutValues_.leftMargin;
515 var fadeDistance = 20; 515 var fadeDistance = 20;
516 var gradient = 516 var gradient =
517 '-webkit-linear-gradient(left,' + 517 '-webkit-linear-gradient(left,' +
518 'transparent, ' + 518 'transparent, ' +
519 'transparent ' + (leftMargin - fadeDistance) + 'px, ' + 519 'transparent ' + (leftMargin - fadeDistance) + 'px, ' +
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 /** 684 /**
685 * Performs all actions necessary when the user completes a drop. 685 * Performs all actions necessary when the user completes a drop.
686 * @param {Event} e A mouseover event for the drag drop. 686 * @param {Event} e A mouseover event for the drag drop.
687 * @private 687 * @private
688 */ 688 */
689 doDrop_: function(e) { 689 doDrop_: function(e) {
690 e.stopPropagation(); 690 e.stopPropagation();
691 this.isCurrentDragTarget_ = false; 691 this.isCurrentDragTarget_ = false;
692 692
693 var index = this.currentDropIndex_; 693 var index = this.currentDropIndex_;
694 if ((index == this.dragItemIndex_) && this.withinPageDrag_) 694 // Only change data if this was not a 'null drag'.
695 return; 695 if (!((index == this.dragItemIndex_) && this.withinPageDrag_)) {
696 696 var adjustedIndex = this.currentDropIndex_ +
697 var adjustedIndex = this.currentDropIndex_ + 697 (index > this.dragItemIndex_ ? 1 : 0);
698 (index > this.dragItemIndex_ ? 1 : 0); 698 if (TilePage.currentlyDraggingTile) {
699 if (TilePage.currentlyDraggingTile) { 699 this.tileGrid_.insertBefore(
700 this.tileGrid_.insertBefore( 700 TilePage.currentlyDraggingTile,
701 TilePage.currentlyDraggingTile, 701 this.tileElements_[adjustedIndex]);
702 this.tileElements_[adjustedIndex]); 702 } else {
703 } else { 703 this.addOutsideData(e.dataTransfer, adjustedIndex);
704 this.addOutsideData(e.dataTransfer, adjustedIndex); 704 }
705 } 705 }
706 706
707 this.classList.remove('animating-tile-page'); 707 this.classList.remove('animating-tile-page');
708 this.cleanUpDrag_(); 708 this.cleanUpDrag_();
709 }, 709 },
710 710
711 /** 711 /**
712 * Makes sure all the tiles are in the right place after a drag is over. 712 * Makes sure all the tiles are in the right place after a drag is over.
713 * @private 713 * @private
714 */ 714 */
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 // This should not get called unless there is a non-default 822 // This should not get called unless there is a non-default
823 // implementation. 823 // implementation.
824 assert(false); 824 assert(false);
825 }, 825 },
826 }; 826 };
827 827
828 return { 828 return {
829 TilePage: TilePage, 829 TilePage: TilePage,
830 }; 830 };
831 }); 831 });
OLDNEW
« 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