| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 * @param {!Array.<!Image>} images | 8 * @param {!Array.<!Image>} images |
| 9 */ | 9 */ |
| 10 WebInspector.AnimationScreenshotPopover = function(images) | 10 WebInspector.AnimationScreenshotPopover = function(images) |
| 11 { | 11 { |
| 12 WebInspector.VBox.call(this, true); | 12 WebInspector.VBox.call(this, true); |
| 13 console.assert(images.length); | 13 console.assert(images.length); |
| 14 this.registerRequiredCSS("animation/animationScreenshotPopover.css"); | 14 this.registerRequiredCSS("animation/animationScreenshotPopover.css"); |
| 15 this.contentElement.classList.add("animation-screenshot-popover"); | 15 this.contentElement.classList.add("animation-screenshot-popover"); |
| 16 this._frames = images; | 16 this._frames = images; |
| 17 for (var image of images) { | 17 for (var image of images) { |
| 18 this.contentElement.appendChild(image); | 18 this.contentElement.appendChild(image); |
| 19 image.style.display = "none"; | 19 image.style.display = "none"; |
| 20 } | 20 } |
| 21 this._currentFrame = 0; | 21 this._currentFrame = 0; |
| 22 this._frames[0].style.display = "block"; | 22 this._frames[0].style.display = "block"; |
| 23 this._progressBar = this.contentElement.createChild("div", "animation-progre
ss"); | 23 this._progressBar = this.contentElement.createChild("div", "animation-progre
ss"); |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 WebInspector.AnimationScreenshotPopover.prototype = { | 26 WebInspector.AnimationScreenshotPopover.prototype = { |
| 27 /** |
| 28 * @override |
| 29 */ |
| 27 wasShown: function() | 30 wasShown: function() |
| 28 { | 31 { |
| 29 this._rafId = this.contentElement.window().requestAnimationFrame(this._c
hangeFrame.bind(this)); | 32 this._rafId = this.contentElement.window().requestAnimationFrame(this._c
hangeFrame.bind(this)); |
| 30 }, | 33 }, |
| 31 | 34 |
| 35 /** |
| 36 * @override |
| 37 */ |
| 32 willHide: function() | 38 willHide: function() |
| 33 { | 39 { |
| 34 this.contentElement.window().cancelAnimationFrame(this._rafId); | 40 this.contentElement.window().cancelAnimationFrame(this._rafId); |
| 35 delete this._endDelay; | 41 delete this._endDelay; |
| 36 }, | 42 }, |
| 37 | 43 |
| 38 _changeFrame: function() | 44 _changeFrame: function() |
| 39 { | 45 { |
| 40 this._rafId = this.contentElement.window().requestAnimationFrame(this._c
hangeFrame.bind(this)); | 46 this._rafId = this.contentElement.window().requestAnimationFrame(this._c
hangeFrame.bind(this)); |
| 41 | 47 |
| 42 if (this._endDelay) { | 48 if (this._endDelay) { |
| 43 this._endDelay--; | 49 this._endDelay--; |
| 44 return; | 50 return; |
| 45 } | 51 } |
| 46 this._showFrame = !this._showFrame; | 52 this._showFrame = !this._showFrame; |
| 47 if (!this._showFrame) | 53 if (!this._showFrame) |
| 48 return; | 54 return; |
| 49 | 55 |
| 50 var numFrames = this._frames.length; | 56 var numFrames = this._frames.length; |
| 51 this._frames[this._currentFrame % numFrames].style.display = "none"; | 57 this._frames[this._currentFrame % numFrames].style.display = "none"; |
| 52 this._currentFrame++; | 58 this._currentFrame++; |
| 53 this._frames[(this._currentFrame) % numFrames].style.display = "block"; | 59 this._frames[(this._currentFrame) % numFrames].style.display = "block"; |
| 54 if (this._currentFrame % numFrames === numFrames - 1) | 60 if (this._currentFrame % numFrames === numFrames - 1) |
| 55 this._endDelay = 50; | 61 this._endDelay = 50; |
| 56 this._progressBar.style.width = (this._currentFrame % numFrames + 1) / n
umFrames * 100 + "%"; | 62 this._progressBar.style.width = (this._currentFrame % numFrames + 1) / n
umFrames * 100 + "%"; |
| 57 }, | 63 }, |
| 58 | 64 |
| 59 __proto__: WebInspector.VBox.prototype | 65 __proto__: WebInspector.VBox.prototype |
| 60 }; | 66 }; |
| OLD | NEW |