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

Side by Side Diff: Source/devtools/front_end/animation/AnimationGroupPreviewUI.js

Issue 1218433007: Devtools Animations: Add buffer and effect selection to animation timeline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix test Created 5 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/animation/AnimationModel.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) 2015 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 * @constructor
7 * @param {!WebInspector.AnimationModel.AnimationGroup} model
8 */
9 WebInspector.AnimationGroupPreviewUI = function(model)
10 {
11 this._model = model;
12 this.element = createElementWithClass("div", "animation-buffer-preview");
13 this._svg = this.element.createSVGChild("svg");
14 this._svg.setAttribute("width", "100%");
15 this._svg.setAttribute("preserveAspectRatio", "none");
16 this._svg.setAttribute("height", "100%");
17 this._svg.setAttribute("viewBox", "0 0 100 27");
18 this._svg.setAttribute("shape-rendering", "crispEdges");
19 this._render();
20 }
21
22 WebInspector.AnimationGroupPreviewUI.prototype = {
23 /**
24 * @return {number}
25 */
26 _groupDuration: function()
27 {
28 var duration = 0;
29 for (var anim of this._model.animations()) {
30 var animDuration = anim.source().delay() + anim.source().duration();
31 if (animDuration > duration)
32 duration = animDuration;
33 }
34 return duration;
35 },
36
37 _render: function()
38 {
39 this._svg.removeChildren();
40 const numberOfAnimations = Math.min(this._model.animations().length, 10) ;
41 var timeToPixelRatio = 100 / Math.max(this._groupDuration(), 300);
42 for (var i = 0; i < numberOfAnimations; i++) {
43 var effect = this._model.animations()[i].source();
44 var line = this._svg.createSVGChild("line");
45 line.setAttribute("x1", effect.delay() * timeToPixelRatio);
46 line.setAttribute("x2", (effect.delay() + effect.duration()) * timeT oPixelRatio);
47 var y = Math.floor(27 / numberOfAnimations * i) + 1;
48 line.setAttribute("y1", y);
49 line.setAttribute("y2", y);
50 line.style.stroke = WebInspector.AnimationUI.Color(this._model.anima tions()[i]);
51 }
52 }
53 }
OLDNEW
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/animation/AnimationModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698