| OLD | NEW |
| 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 * The overlay displaying the image. | 8 * The overlay displaying the image. |
| 9 * | 9 * |
| 10 * @param {HTMLElement} container The container element. | 10 * @param {HTMLElement} container The container element. |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 */ | 257 */ |
| 258 ImageView.prototype.load = | 258 ImageView.prototype.load = |
| 259 function(item, effect, displayCallback, loadCallback) { | 259 function(item, effect, displayCallback, loadCallback) { |
| 260 var entry = item.getEntry(); | 260 var entry = item.getEntry(); |
| 261 var metadata = item.getMetadata() || {}; | 261 var metadata = item.getMetadata() || {}; |
| 262 | 262 |
| 263 if (effect) { | 263 if (effect) { |
| 264 // Skip effects when reloading repeatedly very quickly. | 264 // Skip effects when reloading repeatedly very quickly. |
| 265 var time = Date.now(); | 265 var time = Date.now(); |
| 266 if (this.lastLoadTime_ && | 266 if (this.lastLoadTime_ && |
| 267 (time - this.lastLoadTime_) < ImageView.FAST_SCROLL_INTERVAL) { | 267 (time - this.lastLoadTime_) < ImageView.FAST_SCROLL_INTERVAL) { |
| 268 effect = null; | 268 effect = null; |
| 269 } | 269 } |
| 270 this.lastLoadTime_ = time; | 270 this.lastLoadTime_ = time; |
| 271 } | 271 } |
| 272 | 272 |
| 273 ImageUtil.metrics.startInterval(ImageUtil.getMetricName('DisplayTime')); | 273 ImageUtil.metrics.startInterval(ImageUtil.getMetricName('DisplayTime')); |
| 274 | 274 |
| 275 var self = this; | 275 var self = this; |
| 276 | 276 |
| 277 this.contentItem_ = item; | 277 this.contentItem_ = item; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 ImageView.prototype.unload = function(zoomToRect) { | 409 ImageView.prototype.unload = function(zoomToRect) { |
| 410 if (this.unloadTimer_) { | 410 if (this.unloadTimer_) { |
| 411 clearTimeout(this.unloadTimer_); | 411 clearTimeout(this.unloadTimer_); |
| 412 this.unloadTimer_ = null; | 412 this.unloadTimer_ = null; |
| 413 } | 413 } |
| 414 if (zoomToRect && this.screenImage_) { | 414 if (zoomToRect && this.screenImage_) { |
| 415 var effect = this.createZoomEffect(zoomToRect); | 415 var effect = this.createZoomEffect(zoomToRect); |
| 416 this.setTransform_(this.screenImage_, this.viewport_, effect); | 416 this.setTransform_(this.screenImage_, this.viewport_, effect); |
| 417 this.screenImage_.setAttribute('fade', true); | 417 this.screenImage_.setAttribute('fade', true); |
| 418 this.unloadTimer_ = setTimeout(function() { | 418 this.unloadTimer_ = setTimeout(function() { |
| 419 this.unloadTimer_ = null; | 419 this.unloadTimer_ = null; |
| 420 this.unload(null /* force unload */); | 420 this.unload(null /* force unload */); |
| 421 }.bind(this), | 421 }.bind(this), effect.getSafeInterval()); |
| 422 effect.getSafeInterval()); | |
| 423 return; | 422 return; |
| 424 } | 423 } |
| 425 this.container_.textContent = ''; | 424 this.container_.textContent = ''; |
| 426 this.contentCanvas_ = null; | 425 this.contentCanvas_ = null; |
| 427 this.screenImage_ = null; | 426 this.screenImage_ = null; |
| 428 }; | 427 }; |
| 429 | 428 |
| 430 /** | 429 /** |
| 431 * @param {HTMLCanvasElement} content The image element. | 430 * @param {HTMLCanvasElement} content The image element. |
| 432 * @param {number=} opt_width Image width. | 431 * @param {number=} opt_width Image width. |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 690 |
| 692 /** | 691 /** |
| 693 * @return {string} CSS transition timing function name. | 692 * @return {string} CSS transition timing function name. |
| 694 */ | 693 */ |
| 695 ImageView.Effect.prototype.getTiming = function() { return this.timing_; }; | 694 ImageView.Effect.prototype.getTiming = function() { return this.timing_; }; |
| 696 | 695 |
| 697 /** | 696 /** |
| 698 * Obtains the CSS transformation string of the effect. | 697 * Obtains the CSS transformation string of the effect. |
| 699 * @param {DOMCanvas} element Canvas element to be applied the transformation. | 698 * @param {DOMCanvas} element Canvas element to be applied the transformation. |
| 700 * @param {Viewport} viewport Current viewport. | 699 * @param {Viewport} viewport Current viewport. |
| 701 * @return CSS transformation description. | 700 * @return {string} CSS transformation description. |
| 702 */ | 701 */ |
| 703 ImageView.Effect.prototype.transform = function(element, viewport) { | 702 ImageView.Effect.prototype.transform = function(element, viewport) { |
| 704 throw new Error('Not implemented.'); | 703 throw new Error('Not implemented.'); |
| 704 return ''; |
| 705 }; | 705 }; |
| 706 | 706 |
| 707 /** | 707 /** |
| 708 * Default effect. | 708 * Default effect. |
| 709 * | 709 * |
| 710 * @constructor | 710 * @constructor |
| 711 * @extends {ImageView.Effect} | 711 * @extends {ImageView.Effect} |
| 712 */ | 712 */ |
| 713 ImageView.Effect.None = function() { | 713 ImageView.Effect.None = function() { |
| 714 ImageView.Effect.call(this, 0, 'easy-out'); | 714 ImageView.Effect.call(this, 0, 'easy-out'); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 }; | 832 }; |
| 833 | 833 |
| 834 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; | 834 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; |
| 835 | 835 |
| 836 /** | 836 /** |
| 837 * @override | 837 * @override |
| 838 */ | 838 */ |
| 839 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { | 839 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { |
| 840 return viewport.getInverseTransformForRotatedImage(this.orientation_); | 840 return viewport.getInverseTransformForRotatedImage(this.orientation_); |
| 841 }; | 841 }; |
| OLD | NEW |