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

Side by Side Diff: ui/file_manager/gallery/js/mosaic_mode.js

Issue 624563002: Files.app: Rename Rect used in Gallery with ImageRect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @param {Element} container Content container. 8 * @param {Element} container Content container.
9 * @param {cr.ui.ArrayDataModel} dataModel Data model. 9 * @param {cr.ui.ArrayDataModel} dataModel Data model.
10 * @param {cr.ui.ListSelectionModel} selectionModel Selection model. 10 * @param {cr.ui.ListSelectionModel} selectionModel Selection model.
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 /** 252 /**
253 * @return {Mosaic.Tile} Selected tile or undefined if no selection. 253 * @return {Mosaic.Tile} Selected tile or undefined if no selection.
254 */ 254 */
255 Mosaic.prototype.getSelectedTile = function() { 255 Mosaic.prototype.getSelectedTile = function() {
256 return this.tiles_ && this.tiles_[this.selectionModel_.selectedIndex]; 256 return this.tiles_ && this.tiles_[this.selectionModel_.selectedIndex];
257 }; 257 };
258 258
259 /** 259 /**
260 * @param {number} index Tile index. 260 * @param {number} index Tile index.
261 * @return {Rect} Tile's image rectangle. 261 * @return {ImageRect} Tile's image rectangle.
262 */ 262 */
263 Mosaic.prototype.getTileRect = function(index) { 263 Mosaic.prototype.getTileRect = function(index) {
264 var tile = this.tiles_[index]; 264 var tile = this.tiles_[index];
265 return tile && tile.getImageRect(); 265 return tile && tile.getImageRect();
266 }; 266 };
267 267
268 /** 268 /**
269 * @param {number} index Tile index. 269 * @param {number} index Tile index.
270 * Scroll the given tile into the viewport. 270 * Scroll the given tile into the viewport.
271 */ 271 */
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 546
547 this.loadVisibleTilesSuppressed_ = true; 547 this.loadVisibleTilesSuppressed_ = true;
548 this.loadVisibleTilesScheduled_ = false; 548 this.loadVisibleTilesScheduled_ = false;
549 setTimeout(function() { 549 setTimeout(function() {
550 this.loadVisibleTilesSuppressed_ = false; 550 this.loadVisibleTilesSuppressed_ = false;
551 if (this.loadVisibleTilesScheduled_) 551 if (this.loadVisibleTilesScheduled_)
552 this.loadVisibleTiles_(); 552 this.loadVisibleTiles_();
553 }.bind(this), 100); 553 }.bind(this), 100);
554 554
555 // Tiles only in the viewport (visible). 555 // Tiles only in the viewport (visible).
556 var visibleRect = new Rect(0, 556 var visibleRect = new ImageRect(
557 0, 557 0, 0, this.clientWidth, this.clientHeight);
558 this.clientWidth,
559 this.clientHeight);
560 558
561 // Tiles in the viewport and also some distance on the left and right. 559 // Tiles in the viewport and also some distance on the left and right.
562 var renderableRect = new Rect(-this.clientWidth, 560 var renderableRect = new ImageRect(
563 0, 561 -this.clientWidth,
564 3 * this.clientWidth, 562 0,
565 this.clientHeight); 563 3 * this.clientWidth,
564 this.clientHeight);
566 565
567 // Unload tiles out of scope. 566 // Unload tiles out of scope.
568 for (var index = 0; index < this.tiles_.length; index++) { 567 for (var index = 0; index < this.tiles_.length; index++) {
569 var tile = this.tiles_[index]; 568 var tile = this.tiles_[index];
570 var imageRect = tile.getImageRect(); 569 var imageRect = tile.getImageRect();
571 // Unload a thumbnail. 570 // Unload a thumbnail.
572 if (imageRect && !imageRect.intersects(renderableRect)) 571 if (imageRect && !imageRect.intersects(renderableRect))
573 tile.unload(); 572 tile.unload();
574 } 573 }
575 574
(...skipping 23 matching lines...) Expand all
599 imageRect.intersects(renderableRect)) { 598 imageRect.intersects(renderableRect)) {
600 tile.load(Mosaic.Tile.LoadMode.LOW_DPI, function() {}); 599 tile.load(Mosaic.Tile.LoadMode.LOW_DPI, function() {});
601 } 600 }
602 } 601 }
603 } 602 }
604 }; 603 };
605 604
606 /** 605 /**
607 * Applies reset the zoom transform. 606 * Applies reset the zoom transform.
608 * 607 *
609 * @param {Rect} tileRect Tile rectangle. Reset the transform if null. 608 * @param {ImageRect} tileRect Tile rectangle. Reset the transform if null.
610 * @param {Rect} imageRect Large image rectangle. Reset the transform if null. 609 * @param {ImageRect} imageRect Large image rectangle. Reset the transform if
610 * null.
611 * @param {boolean=} opt_instant True of the transition should be instant. 611 * @param {boolean=} opt_instant True of the transition should be instant.
612 */ 612 */
613 Mosaic.prototype.transform = function(tileRect, imageRect, opt_instant) { 613 Mosaic.prototype.transform = function(tileRect, imageRect, opt_instant) {
614 if (opt_instant) { 614 if (opt_instant) {
615 this.style.webkitTransitionDuration = '0'; 615 this.style.webkitTransitionDuration = '0';
616 } else { 616 } else {
617 this.style.webkitTransitionDuration = 617 this.style.webkitTransitionDuration =
618 ImageView.MODE_TRANSITION_DURATION + 'ms'; 618 ImageView.MODE_TRANSITION_DURATION + 'ms';
619 } 619 }
620 620
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 1961
1962 if (targetPosition) { 1962 if (targetPosition) {
1963 if (opt_animated === false) 1963 if (opt_animated === false)
1964 this.container_.scrollLeft = targetPosition; 1964 this.container_.scrollLeft = targetPosition;
1965 else 1965 else
1966 this.container_.animatedScrollTo(targetPosition); 1966 this.container_.animatedScrollTo(targetPosition);
1967 } 1967 }
1968 }; 1968 };
1969 1969
1970 /** 1970 /**
1971 * @return {Rect} Rectangle occupied by the tile's image, 1971 * @return {ImageRect} Rectangle occupied by the tile's image,
1972 * relative to the viewport. 1972 * relative to the viewport.
1973 */ 1973 */
1974 Mosaic.Tile.prototype.getImageRect = function() { 1974 Mosaic.Tile.prototype.getImageRect = function() {
1975 if (this.left_ === null) // Not laid out. 1975 if (this.left_ === null) // Not laid out.
1976 return null; 1976 return null;
1977 1977
1978 var margin = Mosaic.Layout.SPACING / 2; 1978 var margin = Mosaic.Layout.SPACING / 2;
1979 return new Rect(this.left_ - this.container_.scrollLeft, this.top_, 1979 return new ImageRect(this.left_ - this.container_.scrollLeft, this.top_,
1980 this.width_, this.height_).inflate(-margin, -margin); 1980 this.width_, this.height_).inflate(-margin, -margin);
1981 }; 1981 };
1982 1982
1983 /** 1983 /**
1984 * @return {number} X coordinate of the tile center. 1984 * @return {number} X coordinate of the tile center.
1985 */ 1985 */
1986 Mosaic.Tile.prototype.getCenterX = function() { 1986 Mosaic.Tile.prototype.getCenterX = function() {
1987 return this.left_ + Math.round(this.width_ / 2); 1987 return this.left_ + Math.round(this.width_ / 2);
1988 }; 1988 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/viewport.js ('k') | ui/file_manager/gallery/js/slide_mode.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698