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

Side by Side Diff: Source/devtools/front_end/sdk/AnimationModel.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/front_end/main/Main.js ('k') | Source/devtools/front_end/sdk/Target.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 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5
6 /**
7 * @constructor
8 * @extends {WebInspector.SDKModel}
9 * @param {!WebInspector.Target} target
10 */
11 WebInspector.AnimationModel = function(target) {
12 WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target);
13
14 this._agent = target.animationAgent();
15 }
16
17 WebInspector.AnimationModel.prototype = {
18 /**
19 * @param {!DOMAgent.NodeId} nodeId
20 * @param {function(?Array.<!WebInspector.AnimationModel.AnimationPlayer>)} callback
21 */
22 animationPlayers: function(nodeId, callback)
23 {
24 /**
25 * @param {?Protocol.Error} error
26 * @param {!Array.<!AnimationAgent.AnimationPlayer>} payloads
27 */
28 function mycallback(error, payloads)
29 {
30 if (error) {
31 callback(null);
32 return;
33 }
34 callback(payloads.map(function(payload) {
35 return new WebInspector.AnimationModel.AnimationPlayer(target, p ayload);
36 }));
37 }
38
39 var target = this.target();
40 this._agent.getAnimationPlayersForNode(nodeId, mycallback);
41 },
42
43 __proto__: WebInspector.SDKModel.prototype
44 }
45
46 /**
47 * @constructor
48 * @extends {WebInspector.SDKObject}
49 * @param {!WebInspector.Target} target
50 * @param {!AnimationAgent.AnimationPlayer} payload
51 */
52 WebInspector.AnimationModel.AnimationPlayer = function(target, payload)
53 {
54 WebInspector.SDKObject.call(this, target);
55 this._payload = payload;
56 this._source = new WebInspector.AnimationModel.AnimationNode(this.target(), this._payload.source);
57 }
58
59 WebInspector.AnimationModel.AnimationPlayer.prototype = {
60 /**
61 * @return {!AnimationAgent.AnimationPlayer}
62 */
63 payload: function()
64 {
65 return this._payload;
66 },
67
68 /**
69 * @return {string}
70 */
71 id: function()
72 {
73 return this._payload.id;
74 },
75
76 /**
77 * @return {boolean}
78 */
79 paused: function ()
80 {
81 return this._payload.pausedState;
82 },
83
84 /**
85 * @return {string}
86 */
87 playState: function()
88 {
89 return this._payload.playState;
90 },
91
92 /**
93 * @return {number}
94 */
95 playbackRate: function()
96 {
97 return this._payload.playbackRate;
98 },
99
100 /**
101 * @return {number}
102 */
103 startTime: function()
104 {
105 return this._payload.startTime;
106 },
107
108 /**
109 * @return {number}
110 */
111 currentTime: function()
112 {
113 return this._payload.currentTime;
114 },
115
116 /**
117 * @return {!WebInspector.AnimationModel.AnimationNode}
118 */
119 source: function()
120 {
121 return this._source;
122 },
123
124 /**
125 * @param {function(?WebInspector.AnimationModel.AnimationPlayer)} callback
126 */
127 pause: function(callback)
128 {
129 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Ani mationAgent.pauseAnimationPlayer(): ", WebInspector.AnimationModel.AnimationPlay er.bind(null, this._target));
130 this.target().animationModel._agent.pauseAnimationPlayer(this.id(), wrap pedCallback);
131 },
132
133 /**
134 * @param {function(?WebInspector.AnimationModel.AnimationPlayer)} callback
135 */
136 play: function(callback)
137 {
138 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Ani mationAgent.playAnimationPlayer(): ", WebInspector.AnimationModel.AnimationPlaye r.bind(null, this._target));
139 this.target().animationModel._agent.playAnimationPlayer(this.id(), wrapp edCallback);
140 },
141
142 /**
143 * @param {number} currentTime
144 * @param {function(?WebInspector.AnimationModel.AnimationPlayer)} callback
145 */
146 setCurrentTime: function(currentTime, callback)
147 {
148 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Ani mationAgent.setAnimationPlayerCurrentTime(): ", WebInspector.AnimationModel.Anim ationPlayer.bind(null, this._target));
149 this.target().animationModel._agent.setAnimationPlayerCurrentTime(this.i d(), currentTime, wrappedCallback);
150 },
151
152 /**
153 * @param {function(number, boolean)} callback
154 */
155 getCurrentState: function(callback)
156 {
157 /**
158 * @param {?Protocol.Error} error
159 * @param {number} currentTime
160 * @param {boolean} isRunning
161 */
162 function mycallback(error, currentTime, isRunning)
163 {
164 if (error) {
165 console.error(error);
166 return;
167 }
168 callback(currentTime, isRunning);
169 }
170 this.target().animationModel._agent.getAnimationPlayerState(this.id(), m ycallback);
171 },
172
173 __proto__: WebInspector.SDKObject.prototype
174 }
175
176 /**
177 * @constructor
178 * @extends {WebInspector.SDKObject}
179 * @param {!WebInspector.Target} target
180 * @param {!AnimationAgent.AnimationNode} payload
181 */
182 WebInspector.AnimationModel.AnimationNode = function(target, payload)
183 {
184 WebInspector.SDKObject.call(this, target);
185 this._payload = payload;
186 }
187
188 WebInspector.AnimationModel.AnimationNode.prototype = {
189 /**
190 * @return {number}
191 */
192 startDelay: function()
193 {
194 return this._payload.startDelay;
195 },
196
197 /**
198 * @return {number}
199 */
200 playbackRate: function()
201 {
202 return this._payload.playbackRate;
203 },
204
205 /**
206 * @return {number}
207 */
208 iterationStart: function()
209 {
210 return this._payload.iterationStart;
211 },
212
213 /**
214 * @return {number}
215 */
216 iterationCount: function()
217 {
218 return this._payload.iterationCount;
219 },
220
221 /**
222 * @return {number}
223 */
224 duration: function()
225 {
226 return this._payload.duration;
227 },
228
229 /**
230 * @return {number}
231 */
232 direction: function()
233 {
234 return this._payload.direction;
235 },
236
237 /**
238 * @return {number}
239 */
240 fillMode: function()
241 {
242 return this._payload.fillMode;
243 },
244
245 /**
246 * @return {number}
247 */
248 timeFraction: function()
249 {
250 return this._payload.timeFraction;
251 },
252
253 /**
254 * @return {string}
255 */
256 name: function()
257 {
258 return this._payload.name;
259 },
260
261 __proto__: WebInspector.SDKObject.prototype
262 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/main/Main.js ('k') | Source/devtools/front_end/sdk/Target.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698