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

Side by Side Diff: Source/devtools/front_end/elements/AnimationSection.js

Issue 620783002: Devtools Animations: Basic animation inspection & control in Styles pane (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.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
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/elements/StylesSidebarPane.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /**
apavlov 2014/10/01 07:39:36 The [short 3-line] copyright notice is missing
samli 2014/10/02 08:30:33 Done.
2 * @constructor
3 * @param {?WebInspector.DOMModel.AnimationPlayer} animationPlayer
4 */
5 WebInspector.AnimationSection = function(animationPlayer)
6 {
7 var section = this;
apavlov 2014/10/01 07:39:35 This should go just before the createCurrentTimeSl
samli 2014/10/02 08:30:33 Done.
8 this.element = document.createElement("div");
9 this.element.className = "styles-section";
10 this.element._section = this;
11 this.propertiesElement = document.createElement("div");
12 this.player = animationPlayer;
apavlov 2014/10/01 07:39:36 We typically assign the constructor arguments firs
samli 2014/10/02 08:30:33 Done.
13 this.animationControls = createAnimationControls();
14 this.element.appendChild(this.animationControls);
15 this.element.appendChild(this.propertiesElement);
16
17 /**
18 * @return {!Element}
19 */
20 function createCurrentTimeSlider() {
apavlov 2014/10/01 07:39:35 Brace on the next line. I also think this should b
samli 2014/10/02 08:30:34 Done.
21 var slider = document.createElement("input");
22 var iterationDuration = section.player.animation().duration();
23 var iterationCount = section.player.animation().iterationCount();
24 slider.type = "range";
apavlov 2014/10/01 07:39:35 It's best to glue these to the "var slider" declar
samli 2014/10/02 08:30:33 Done.
25 slider.min = 0;
26 slider.step = 0.01;
27
28 if (!iterationCount) {
29 // Infinite iterations
30 slider.max = iterationDuration;
31 slider.value = section.player.currentTime() % iterationDuration;
32 } else {
33 slider.max = iterationCount * iterationDuration;
34 slider.value = section.player.currentTime();
35 }
36
37 slider.addEventListener('input', function (e) {
apavlov 2014/10/01 07:39:35 DevTools use double quotes for string literals. T
samli 2014/10/02 08:30:33 Done.
38 section.player.setCurrentTime(parseFloat(e.target.value), updateAnim ationPlayer);
39 });
40 requestAnimationFrame(updateCurrentTime);
41 return slider;
42 }
43
44 /**
45 * @return {!Element}
46 */
47 function createAnimationControls() {
apavlov 2014/10/01 07:39:35 Brace on the next line. Ditto for this becoming a
samli 2014/10/02 08:30:33 Done.
48 var controls = document.createElement("div");
49
50 // Pause/play button
51 var pausePlayButton = document.createElement("button");
apavlov 2014/10/01 07:39:35 Not sure, but you might want to take a look at Web
samli 2014/10/02 08:30:33 Ack. Going to look into this tomorrow.
52 if (section.player.paused()) {
apavlov 2014/10/01 07:39:36 no braces around single-line blocks
samli 2014/10/02 08:30:33 Done.
53 pausePlayButton.textContent = WebInspector.UIString("Play");
54 } else {
apavlov 2014/10/01 07:39:36 ditto
samli 2014/10/02 08:30:34 Done.
55 pausePlayButton.textContent = WebInspector.UIString("Pause");
56 }
57 pausePlayButton.addEventListener("click", function () {
apavlov 2014/10/01 07:39:35 Please use a named nested function
samli 2014/10/02 08:30:33 Done.
58 if (section.player.paused()) {
59 section.player.play(updateAnimationPlayer);
60 pausePlayButton.textContent = WebInspector.UIString("Pause");
61 } else {
62 section.player.pause(updateAnimationPlayer);
63 pausePlayButton.textContent = WebInspector.UIString("Play");
64 }
65 });
66 controls.appendChild(pausePlayButton);
67
68 // Current time slider
69 section.currentTimeSlider = createCurrentTimeSlider();
70 controls.appendChild(section.currentTimeSlider);
71
72 return controls;
73 }
74
75 /**
76 * @param {?WebInspector.DOMModel.AnimationPlayer} animationPlayer
77 */
78 function updateAnimationPlayer(animationPlayer) {
apavlov 2014/10/01 07:39:35 brace on the next line
samli 2014/10/02 08:30:33 Done.
79 if (animationPlayer)
apavlov 2014/10/01 07:39:36 Is this missing braces around the next two lines o
samli 2014/10/02 08:30:33 Acknowledged.
80 section.player = animationPlayer;
81 requestAnimationFrame(updateCurrentTime);
82 }
83
84 function updateCurrentTime() {
apavlov 2014/10/01 07:39:35 brace on the next line
samli 2014/10/02 08:30:33 Done.
85 section.player.getCurrentState(function (currentTime, isRunning) {
apavlov 2014/10/01 07:39:36 Annotated named function, please
samli 2014/10/02 08:30:33 Done.
86 section.currentTimeSlider.value = section.player.animation().iterati onCount() == null ? currentTime % section.player.animation().duration() : curren tTime;
87 if (isRunning) {
apavlov 2014/10/01 07:39:35 no braces around single-line blocks
samli 2014/10/02 08:30:34 Done.
88 requestAnimationFrame(updateCurrentTime);
89 }
90 });
91 }
92 }
93
94 WebInspector.AnimationSection.prototype = {
95 get player()
apavlov 2014/10/01 07:39:36 We do not use getters and setters in the new code.
samli 2014/10/02 08:30:33 Done.
96 {
97 return this._animationPlayer;
98 },
99 set player(p)
apavlov 2014/10/01 07:39:35 blank line above
samli 2014/10/02 08:30:33 Done.
100 {
101 if (p === this._animationPlayer)
102 return;
103
104 this._animationPlayer = p;
105
106 if (p instanceof WebInspector.DOMModel.AnimationPlayer) {
107 this.propertiesElement.removeChildren();
108 var animationObject = {
109 'paused': p.paused(),
apavlov 2014/10/01 07:39:36 Double-quotes for string literals
samli 2014/10/02 08:30:33 Done.
110 'finished': p.finished(),
111 'start-time': p.startTime(),
112 'player-playback-rate': p.playbackRate(),
113 'id': p.sequenceNumber(),
114 'start-delay': p.animation().startDelay(),
115 'playback-rate': p.animation().playbackRate(),
116 'iteration-start': p.animation().iterationStart(),
117 'iteration-count': p.animation().iterationCount(),
118 'duration': p.animation().duration(),
119 'direction': p.animation().direction(),
120 'fill-mode': p.animation().fillMode(),
121 'time-fraction': p.animation().timeFraction()
122 };
123 var obj = WebInspector.RemoteObject.fromLocalObject(animationObject) ;
124 var section = new WebInspector.ObjectPropertiesSection(obj, WebInspe ctor.UIString("Animation Properties"), undefined, null, undefined, undefined);
apavlov 2014/10/01 07:39:36 You only need the first two arguments here. Please
samli 2014/10/02 08:30:33 Done.
125 this.propertiesElement.appendChild(section.element);
126 }
127 },
apavlov 2014/10/01 07:39:35 extra comma
samli 2014/10/02 08:30:33 Done.
128 }
OLDNEW
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/elements/StylesSidebarPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698