| 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 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
| 9 */ | 9 */ |
| 10 WebInspector.AnimationTimeline = function() | 10 WebInspector.AnimationTimeline = function() |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 this.contentElement.appendChild(this._createHeader()); | 22 this.contentElement.appendChild(this._createHeader()); |
| 23 this._animationsContainer = this.contentElement.createChild("div", "animatio
n-timeline-rows"); | 23 this._animationsContainer = this.contentElement.createChild("div", "animatio
n-timeline-rows"); |
| 24 this._duration = this._defaultDuration(); | 24 this._duration = this._defaultDuration(); |
| 25 this._scrubberRadius = 25; | 25 this._scrubberRadius = 25; |
| 26 this._timelineControlsWidth = 200; | 26 this._timelineControlsWidth = 200; |
| 27 /** @type {!Map.<!DOMAgent.BackendNodeId, !WebInspector.AnimationTimeline.No
deUI>} */ | 27 /** @type {!Map.<!DOMAgent.BackendNodeId, !WebInspector.AnimationTimeline.No
deUI>} */ |
| 28 this._nodesMap = new Map(); | 28 this._nodesMap = new Map(); |
| 29 this._symbol = Symbol("animationTimeline"); | 29 this._symbol = Symbol("animationTimeline"); |
| 30 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationPlayer>} */ | 30 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationPlayer>} */ |
| 31 this._animationsMap = new Map(); | 31 this._animationsMap = new Map(); |
| 32 this._editorPopoverHelper = new WebInspector.EditorPopoverHelper(); |
| 33 this._bezierEditor = new WebInspector.BezierEditor(); |
| 34 |
| 32 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel,
WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNav
igated, this); | 35 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel,
WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNav
igated, this); |
| 33 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec
tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); | 36 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec
tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); |
| 34 | 37 |
| 35 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag
e); | 38 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag
e); |
| 36 } | 39 } |
| 37 | 40 |
| 38 WebInspector.AnimationTimeline.GlobalPlaybackRates = [0.1, 0.25, 0.5, 1.0]; | 41 WebInspector.AnimationTimeline.GlobalPlaybackRates = [0.1, 0.25, 0.5, 1.0]; |
| 39 | 42 |
| 40 WebInspector.AnimationTimeline.prototype = { | 43 WebInspector.AnimationTimeline.prototype = { |
| 41 wasShown: function() | 44 wasShown: function() |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 */ | 618 */ |
| 616 WebInspector.AnimationTimeline.NodeUI = function(animationNode) { | 619 WebInspector.AnimationTimeline.NodeUI = function(animationNode) { |
| 617 /** | 620 /** |
| 618 * @param {?WebInspector.DOMNode} node | 621 * @param {?WebInspector.DOMNode} node |
| 619 * @this {WebInspector.AnimationTimeline.NodeUI} | 622 * @this {WebInspector.AnimationTimeline.NodeUI} |
| 620 */ | 623 */ |
| 621 function nodeResolved(node) | 624 function nodeResolved(node) |
| 622 { | 625 { |
| 623 this._node = node; | 626 this._node = node; |
| 624 this._description.appendChild(WebInspector.DOMPresentationUtils.linkifyN
odeReference(node)); | 627 this._description.appendChild(WebInspector.DOMPresentationUtils.linkifyN
odeReference(node)); |
| 625 this.element.addEventListener("click", WebInspector.Revealer.reveal.bind
(WebInspector.Revealer, node, undefined), false); | 628 this.element.addEventListener("mousedown", WebInspector.Revealer.reveal.
bind(WebInspector.Revealer, node, undefined), false); |
| 626 } | 629 } |
| 627 | 630 |
| 628 this._rows = []; | 631 this._rows = []; |
| 629 this.element = createElementWithClass("div", "animation-node-row"); | 632 this.element = createElementWithClass("div", "animation-node-row"); |
| 630 this._description = this.element.createChild("div", "animation-node-descript
ion"); | 633 this._description = this.element.createChild("div", "animation-node-descript
ion"); |
| 631 animationNode.deferredNode().resolve(nodeResolved.bind(this)); | 634 animationNode.deferredNode().resolve(nodeResolved.bind(this)); |
| 632 this._timelineElement = this.element.createChild("div", "animation-node-time
line"); | 635 this._timelineElement = this.element.createChild("div", "animation-node-time
line"); |
| 633 } | 636 } |
| 634 | 637 |
| 635 /** @typedef {{element: !Element, animations: !Array<!WebInspector.AnimationUI>}
} */ | 638 /** @typedef {{element: !Element, animations: !Array<!WebInspector.AnimationUI>}
} */ |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 * @constructor | 726 * @constructor |
| 724 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation | 727 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation |
| 725 * @param {!WebInspector.AnimationTimeline} timeline | 728 * @param {!WebInspector.AnimationTimeline} timeline |
| 726 * @param {!Element} parentElement | 729 * @param {!Element} parentElement |
| 727 */ | 730 */ |
| 728 WebInspector.AnimationUI = function(animation, timeline, parentElement) { | 731 WebInspector.AnimationUI = function(animation, timeline, parentElement) { |
| 729 this._animation = animation; | 732 this._animation = animation; |
| 730 this._timeline = timeline; | 733 this._timeline = timeline; |
| 731 this._parentElement = parentElement; | 734 this._parentElement = parentElement; |
| 732 | 735 |
| 733 if (this._animation.source().keyframesRule()) | |
| 734 this._keyframes = this._animation.source().keyframesRule().keyframes(); | |
| 735 | |
| 736 this._nameElement = parentElement.createChild("div", "animation-name"); | 736 this._nameElement = parentElement.createChild("div", "animation-name"); |
| 737 this._nameElement.textContent = this._animation.name(); | 737 this._nameElement.textContent = this._animation.name(); |
| 738 | 738 |
| 739 this._bezierIconElement = WebInspector.BezierPopoverIcon.createIcon(parentEl
ement); |
| 740 this._bezierIconElement.style.backgroundColor = this._color(); |
| 741 this._bezierIconElement.addEventListener("mousedown", this._toggleBezierEdit
or.bind(this)); |
| 742 |
| 739 this._svg = parentElement.createSVGChild("svg", "animation-ui"); | 743 this._svg = parentElement.createSVGChild("svg", "animation-ui"); |
| 740 this._svg.setAttribute("height", WebInspector.AnimationUI.Options.AnimationS
VGHeight); | 744 this._svg.setAttribute("height", WebInspector.AnimationUI.Options.AnimationS
VGHeight); |
| 741 this._svg.style.marginLeft = "-" + WebInspector.AnimationUI.Options.Animatio
nMargin + "px"; | 745 this._svg.style.marginLeft = "-" + WebInspector.AnimationUI.Options.Animatio
nMargin + "px"; |
| 742 this._svg.addEventListener("mousedown", this._mouseDown.bind(this, WebInspec
tor.AnimationUI.MouseEvents.AnimationDrag, null)); | 746 this._svg.addEventListener("mousedown", this._mouseDown.bind(this, WebInspec
tor.AnimationUI.MouseEvents.AnimationDrag, null)); |
| 743 this._activeIntervalGroup = this._svg.createSVGChild("g"); | 747 this._activeIntervalGroup = this._svg.createSVGChild("g"); |
| 748 this._activeIntervalGroup.addEventListener("mouseover", this._toggleBezierIc
on.bind(this, true)); |
| 749 this._activeIntervalGroup.addEventListener("mouseout", this._toggleBezierIco
n.bind(this, false)); |
| 744 | 750 |
| 745 /** @type {!Array.<{group: ?Element, animationLine: ?Element, keyframePoints
: !Object.<number, !Element>, keyframeRender: !Object.<number, !Element>}>} */ | 751 /** @type {!Array.<{group: ?Element, animationLine: ?Element, keyframePoints
: !Object.<number, !Element>, keyframeRender: !Object.<number, !Element>}>} */ |
| 746 this._cachedElements = []; | 752 this._cachedElements = []; |
| 747 | 753 |
| 748 this._movementInMs = 0; | 754 this._movementInMs = 0; |
| 749 this.redraw(); | 755 this.redraw(); |
| 750 } | 756 } |
| 751 | 757 |
| 752 /** | 758 /** |
| 753 * @enum {string} | 759 * @enum {string} |
| 754 */ | 760 */ |
| 755 WebInspector.AnimationUI.MouseEvents = { | 761 WebInspector.AnimationUI.MouseEvents = { |
| 756 AnimationDrag: "AnimationDrag", | 762 AnimationDrag: "AnimationDrag", |
| 757 KeyframeMove: "KeyframeMove", | 763 KeyframeMove: "KeyframeMove", |
| 758 StartEndpointMove: "StartEndpointMove", | 764 StartEndpointMove: "StartEndpointMove", |
| 759 FinishEndpointMove: "FinishEndpointMove" | 765 FinishEndpointMove: "FinishEndpointMove" |
| 760 } | 766 } |
| 761 | 767 |
| 762 WebInspector.AnimationUI.prototype = { | 768 WebInspector.AnimationUI.prototype = { |
| 763 /** | 769 /** |
| 764 * @return {!WebInspector.AnimationModel.AnimationPlayer} | 770 * @return {!WebInspector.AnimationModel.AnimationPlayer} |
| 765 */ | 771 */ |
| 766 animation: function() | 772 animation: function() |
| 767 { | 773 { |
| 768 return this._animation; | 774 return this._animation; |
| 769 }, | 775 }, |
| 770 | 776 |
| 771 /** | 777 /** |
| 778 * @return {?Array.<!WebInspector.AnimationModel.KeyframeStyle>} |
| 779 */ |
| 780 _keyframes: function() |
| 781 { |
| 782 return this._animation.source().keyframesRule() ? this._animation.source
().keyframesRule().keyframes() : null; |
| 783 }, |
| 784 |
| 785 /** |
| 772 * @param {?WebInspector.DOMNode} node | 786 * @param {?WebInspector.DOMNode} node |
| 773 */ | 787 */ |
| 774 setNode: function(node) | 788 setNode: function(node) |
| 775 { | 789 { |
| 776 this._node = node; | 790 this._node = node; |
| 777 }, | 791 }, |
| 778 | 792 |
| 779 /** | 793 /** |
| 780 * @param {!Element} parentElement | 794 * @param {!Element} parentElement |
| 781 * @param {string} className | 795 * @param {string} className |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 var durationWithDelay = this._delay() + this._duration() * this._animati
on.source().iterations() + this._animation.source().endDelay(); | 920 var durationWithDelay = this._delay() + this._duration() * this._animati
on.source().iterations() + this._animation.source().endDelay(); |
| 907 var leftMargin = ((this._animation.startTime() - this._timeline.startTim
e()) * this._timeline.pixelMsRatio()); | 921 var leftMargin = ((this._animation.startTime() - this._timeline.startTim
e()) * this._timeline.pixelMsRatio()); |
| 908 var maxWidth = this._timeline.width() - WebInspector.AnimationUI.Options
.AnimationMargin - leftMargin; | 922 var maxWidth = this._timeline.width() - WebInspector.AnimationUI.Options
.AnimationMargin - leftMargin; |
| 909 var svgWidth = Math.min(maxWidth, durationWithDelay * this._timeline.pix
elMsRatio()); | 923 var svgWidth = Math.min(maxWidth, durationWithDelay * this._timeline.pix
elMsRatio()); |
| 910 | 924 |
| 911 this._svg.classList.toggle("animation-ui-canceled", this._animation.play
State() === "idle"); | 925 this._svg.classList.toggle("animation-ui-canceled", this._animation.play
State() === "idle"); |
| 912 this._svg.setAttribute("width", (svgWidth + 2 * WebInspector.AnimationUI
.Options.AnimationMargin).toFixed(2)); | 926 this._svg.setAttribute("width", (svgWidth + 2 * WebInspector.AnimationUI
.Options.AnimationMargin).toFixed(2)); |
| 913 this._svg.style.transform = "translateX(" + leftMargin.toFixed(2) + "px
)"; | 927 this._svg.style.transform = "translateX(" + leftMargin.toFixed(2) + "px
)"; |
| 914 this._activeIntervalGroup.style.transform = "translateX(" + (this._delay
() * this._timeline.pixelMsRatio()).toFixed(2) + "px)"; | 928 this._activeIntervalGroup.style.transform = "translateX(" + (this._delay
() * this._timeline.pixelMsRatio()).toFixed(2) + "px)"; |
| 915 | 929 |
| 916 this._nameElement.style.transform = "translateX(" + (leftMargin + this._
delay() * this._timeline.pixelMsRatio() + WebInspector.AnimationUI.Options.Anima
tionMargin).toFixed(2) + "px)"; | 930 var leftPosition = (leftMargin + this._delay() * this._timeline.pixelMsR
atio() + WebInspector.AnimationUI.Options.AnimationMargin).toFixed(2); |
| 931 this._nameElement.style.transform = "translateX(" + leftPosition + "px)"
; |
| 932 this._bezierIconElement.classList.toggle("hidden", this._animation.playS
tate() === "idle"); |
| 933 this._bezierIconElement.style.marginLeft = leftPosition + "px"; |
| 917 this._nameElement.style.width = (this._duration() * this._timeline.pixel
MsRatio().toFixed(2)) + "px"; | 934 this._nameElement.style.width = (this._duration() * this._timeline.pixel
MsRatio().toFixed(2)) + "px"; |
| 918 this._drawDelayLine(this._svg); | 935 this._drawDelayLine(this._svg); |
| 919 | 936 |
| 920 if (this._animation.type() === "CSSTransition") { | 937 if (this._animation.type() === "CSSTransition") { |
| 921 this._renderTransition(); | 938 this._renderTransition(); |
| 922 return; | 939 return; |
| 923 } | 940 } |
| 924 | 941 |
| 925 this._renderIteration(this._activeIntervalGroup, 0); | 942 this._renderIteration(this._activeIntervalGroup, 0); |
| 926 if (!this._tailGroup) | 943 if (!this._tailGroup) |
| 927 this._tailGroup = this._activeIntervalGroup.createSVGChild("g", "ani
mation-tail-iterations"); | 944 this._tailGroup = this._activeIntervalGroup.createSVGChild("g", "ani
mation-tail-iterations"); |
| 928 var iterationWidth = this._duration() * this._timeline.pixelMsRatio(); | 945 var iterationWidth = this._duration() * this._timeline.pixelMsRatio(); |
| 929 for (var iteration = 1; iteration < this._animation.source().iterations(
) && iterationWidth * (iteration - 1) < this._timeline.width(); iteration++) | 946 for (var iteration = 1; iteration < this._animation.source().iterations(
) && iterationWidth * (iteration - 1) < this._timeline.width(); iteration++) |
| 930 this._renderIteration(this._tailGroup, iteration); | 947 this._renderIteration(this._tailGroup, iteration); |
| 931 while (iteration < this._cachedElements.length) | 948 while (iteration < this._cachedElements.length) |
| 932 this._cachedElements.pop().group.remove(); | 949 this._cachedElements.pop().group.remove(); |
| 933 }, | 950 }, |
| 934 | 951 |
| 935 | |
| 936 _renderTransition: function() | 952 _renderTransition: function() |
| 937 { | 953 { |
| 938 if (!this._cachedElements[0]) | 954 if (!this._cachedElements[0]) |
| 939 this._cachedElements[0] = { animationLine: null, keyframePoints: {},
keyframeRender: {}, group: null }; | 955 this._cachedElements[0] = { animationLine: null, keyframePoints: {},
keyframeRender: {}, group: null }; |
| 940 this._drawAnimationLine(0, this._activeIntervalGroup); | 956 this._drawAnimationLine(0, this._activeIntervalGroup); |
| 941 this._renderKeyframe(0, 0, this._activeIntervalGroup, WebInspector.Anima
tionUI.Options.AnimationMargin, this._duration() * this._timeline.pixelMsRatio()
, this._animation.source().easing()); | 957 this._renderKeyframe(0, 0, this._activeIntervalGroup, WebInspector.Anima
tionUI.Options.AnimationMargin, this._duration() * this._timeline.pixelMsRatio()
, this._animation.source().easing()); |
| 942 this._drawPoint(0, this._activeIntervalGroup, WebInspector.AnimationUI.O
ptions.AnimationMargin, 0, true); | 958 this._drawPoint(0, this._activeIntervalGroup, WebInspector.AnimationUI.O
ptions.AnimationMargin, 0, true); |
| 943 this._drawPoint(0, this._activeIntervalGroup, this._duration() * this._t
imeline.pixelMsRatio() + WebInspector.AnimationUI.Options.AnimationMargin, -1, t
rue); | 959 this._drawPoint(0, this._activeIntervalGroup, this._duration() * this._t
imeline.pixelMsRatio() + WebInspector.AnimationUI.Options.AnimationMargin, -1, t
rue); |
| 944 }, | 960 }, |
| 945 | 961 |
| 946 /** | 962 /** |
| 947 * @param {!Element} parentElement | 963 * @param {!Element} parentElement |
| 948 * @param {number} iteration | 964 * @param {number} iteration |
| 949 */ | 965 */ |
| 950 _renderIteration: function(parentElement, iteration) | 966 _renderIteration: function(parentElement, iteration) |
| 951 { | 967 { |
| 952 if (!this._cachedElements[iteration]) | 968 if (!this._cachedElements[iteration]) |
| 953 this._cachedElements[iteration] = { animationLine: null, keyframePoi
nts: {}, keyframeRender: {}, group: parentElement.createSVGChild("g") }; | 969 this._cachedElements[iteration] = { animationLine: null, keyframePoi
nts: {}, keyframeRender: {}, group: parentElement.createSVGChild("g") }; |
| 954 var group = this._cachedElements[iteration].group; | 970 var group = this._cachedElements[iteration].group; |
| 955 group.style.transform = "translateX(" + (iteration * this._duration() *
this._timeline.pixelMsRatio()).toFixed(2) + "px)"; | 971 group.style.transform = "translateX(" + (iteration * this._duration() *
this._timeline.pixelMsRatio()).toFixed(2) + "px)"; |
| 956 this._drawAnimationLine(iteration, group); | 972 this._drawAnimationLine(iteration, group); |
| 957 console.assert(this._keyframes.length > 1); | 973 console.assert(this._keyframes().length > 1); |
| 958 for (var i = 0; i < this._keyframes.length - 1; i++) { | 974 for (var i = 0; i < this._keyframes().length - 1; i++) { |
| 959 var leftDistance = this._offset(i) * this._duration() * this._timeli
ne.pixelMsRatio() + WebInspector.AnimationUI.Options.AnimationMargin; | 975 var leftDistance = this._offset(i) * this._duration() * this._timeli
ne.pixelMsRatio() + WebInspector.AnimationUI.Options.AnimationMargin; |
| 960 var width = this._duration() * (this._offset(i + 1) - this._offset(i
)) * this._timeline.pixelMsRatio(); | 976 var width = this._duration() * (this._offset(i + 1) - this._offset(i
)) * this._timeline.pixelMsRatio(); |
| 961 this._renderKeyframe(iteration, i, group, leftDistance, width, this.
_keyframes[i].easing()); | 977 this._renderKeyframe(iteration, i, group, leftDistance, width, this.
_keyframes()[i].easing()); |
| 962 if (i || (!i && iteration === 0)) | 978 if (i || (!i && iteration === 0)) |
| 963 this._drawPoint(iteration, group, leftDistance, i, iteration ===
0); | 979 this._drawPoint(iteration, group, leftDistance, i, iteration ===
0); |
| 964 } | 980 } |
| 965 this._drawPoint(iteration, group, this._duration() * this._timeline.pixe
lMsRatio() + WebInspector.AnimationUI.Options.AnimationMargin, -1, iteration ===
0); | 981 this._drawPoint(iteration, group, this._duration() * this._timeline.pixe
lMsRatio() + WebInspector.AnimationUI.Options.AnimationMargin, -1, iteration ===
0); |
| 966 }, | 982 }, |
| 967 | 983 |
| 968 /** | 984 /** |
| 969 * @return {number} | 985 * @return {number} |
| 970 */ | 986 */ |
| 971 _delay: function() | 987 _delay: function() |
| (...skipping 17 matching lines...) Expand all Loading... |
| 989 duration -= Math.max(this._movementInMs, -this._animation.source().d
elay()); // Cannot have negative delay | 1005 duration -= Math.max(this._movementInMs, -this._animation.source().d
elay()); // Cannot have negative delay |
| 990 return Math.max(0, duration); | 1006 return Math.max(0, duration); |
| 991 }, | 1007 }, |
| 992 | 1008 |
| 993 /** | 1009 /** |
| 994 * @param {number} i | 1010 * @param {number} i |
| 995 * @return {number} offset | 1011 * @return {number} offset |
| 996 */ | 1012 */ |
| 997 _offset: function(i) | 1013 _offset: function(i) |
| 998 { | 1014 { |
| 999 var offset = this._keyframes[i].offsetAsNumber(); | 1015 var offset = this._keyframes()[i].offsetAsNumber(); |
| 1000 if (this._mouseEventType === WebInspector.AnimationUI.MouseEvents.Keyfra
meMove && i === this._keyframeMoved) { | 1016 if (this._mouseEventType === WebInspector.AnimationUI.MouseEvents.Keyfra
meMove && i === this._keyframeMoved) { |
| 1001 console.assert(i > 0 && i < this._keyframes.length - 1, "First and l
ast keyframe cannot be moved"); | 1017 console.assert(i > 0 && i < this._keyframes().length - 1, "First and
last keyframe cannot be moved"); |
| 1002 offset += this._movementInMs / this._animation.source().duration(); | 1018 offset += this._movementInMs / this._animation.source().duration(); |
| 1003 offset = Math.max(offset, this._keyframes[i - 1].offsetAsNumber()); | 1019 offset = Math.max(offset, this._keyframes()[i - 1].offsetAsNumber())
; |
| 1004 offset = Math.min(offset, this._keyframes[i + 1].offsetAsNumber()); | 1020 offset = Math.min(offset, this._keyframes()[i + 1].offsetAsNumber())
; |
| 1005 } | 1021 } |
| 1006 return offset; | 1022 return offset; |
| 1007 }, | 1023 }, |
| 1008 | 1024 |
| 1009 /** | 1025 /** |
| 1010 * @param {!WebInspector.AnimationUI.MouseEvents} mouseEventType | 1026 * @param {!WebInspector.AnimationUI.MouseEvents} mouseEventType |
| 1011 * @param {?number} keyframeIndex | 1027 * @param {?number} keyframeIndex |
| 1012 * @param {!Event} event | 1028 * @param {!Event} event |
| 1013 */ | 1029 */ |
| 1014 _mouseDown: function(mouseEventType, keyframeIndex, event) | 1030 _mouseDown: function(mouseEventType, keyframeIndex, event) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1042 | 1058 |
| 1043 /** | 1059 /** |
| 1044 * @param {!Event} event | 1060 * @param {!Event} event |
| 1045 */ | 1061 */ |
| 1046 _mouseUp: function(event) | 1062 _mouseUp: function(event) |
| 1047 { | 1063 { |
| 1048 this._movementInMs = (event.clientX - this._downMouseX) / this._timeline
.pixelMsRatio(); | 1064 this._movementInMs = (event.clientX - this._downMouseX) / this._timeline
.pixelMsRatio(); |
| 1049 | 1065 |
| 1050 // Commit changes | 1066 // Commit changes |
| 1051 if (this._mouseEventType === WebInspector.AnimationUI.MouseEvents.Keyfra
meMove) | 1067 if (this._mouseEventType === WebInspector.AnimationUI.MouseEvents.Keyfra
meMove) |
| 1052 this._keyframes[this._keyframeMoved].setOffset(this._offset(this._ke
yframeMoved)); | 1068 this._keyframes()[this._keyframeMoved].setOffset(this._offset(this._
keyframeMoved)); |
| 1053 else | 1069 else |
| 1054 this._animation.setTiming(this._delay(), this._duration()); | 1070 this._animation.setTiming(this._delay(), this._duration()); |
| 1055 | 1071 |
| 1056 this._movementInMs = 0; | 1072 this._movementInMs = 0; |
| 1057 | 1073 |
| 1058 this._parentElement.ownerDocument.removeEventListener("mousemove", this.
_mouseMoveHandler); | 1074 this._parentElement.ownerDocument.removeEventListener("mousemove", this.
_mouseMoveHandler); |
| 1059 this._parentElement.ownerDocument.removeEventListener("mouseup", this._m
ouseUpHandler); | 1075 this._parentElement.ownerDocument.removeEventListener("mouseup", this._m
ouseUpHandler); |
| 1060 delete this._mouseMoveHandler; | 1076 delete this._mouseMoveHandler; |
| 1061 delete this._mouseUpHandler; | 1077 delete this._mouseUpHandler; |
| 1062 delete this._mouseEventType; | 1078 delete this._mouseEventType; |
| 1063 delete this._downMouseX; | 1079 delete this._downMouseX; |
| 1064 delete this._keyframeMoved; | 1080 delete this._keyframeMoved; |
| 1065 }, | 1081 }, |
| 1066 | 1082 |
| 1067 /** | 1083 /** |
| 1084 * @param {boolean} show |
| 1085 */ |
| 1086 _toggleBezierIcon: function(show) |
| 1087 { |
| 1088 var bezier = WebInspector.Geometry.CubicBezier.parse(this._animation.sou
rce().easing()); |
| 1089 if (show && !bezier) |
| 1090 return; |
| 1091 this._bezierIconElement.classList.toggle("shown", show); |
| 1092 }, |
| 1093 |
| 1094 /** |
| 1095 * @param {!Event} event |
| 1096 */ |
| 1097 _toggleBezierEditor: function(event) |
| 1098 { |
| 1099 var popover = this._timeline._editorPopoverHelper; |
| 1100 var shouldShow = !popover.isShowing() || this._bezierIconElement !== pop
over.anchorElement(); |
| 1101 |
| 1102 if (popover.isShowing()) |
| 1103 popover.hide(); |
| 1104 |
| 1105 if (shouldShow) { |
| 1106 this._originalEasing = this._animation.source().easing(); |
| 1107 var bezier = WebInspector.Geometry.CubicBezier.parse(this._originalE
asing); |
| 1108 this._timeline._bezierEditor.setBezier(bezier); |
| 1109 this._timeline._bezierEditor.addEventListener(WebInspector.BezierEdi
tor.Events.BezierChanged, this._bezierChanged, this); |
| 1110 var scrollerElement = this._bezierIconElement.enclosingNodeOrSelfWit
hClass(".animation-timeline-rows"); |
| 1111 popover.show(this._timeline._bezierEditor, this._bezierIconElement,
scrollerElement, this._onPopoverHidden.bind(this)); |
| 1112 this._bezierIconElement.classList.add("bezier-editor-open"); |
| 1113 } |
| 1114 event.consume(true); |
| 1115 }, |
| 1116 |
| 1117 /** |
| 1118 * @param {!WebInspector.Event} event |
| 1119 */ |
| 1120 _bezierChanged: function(event) |
| 1121 { |
| 1122 this._setEasing(/** @type {string} */ (event.data)); |
| 1123 }, |
| 1124 |
| 1125 /** |
| 1126 * @param {boolean} commitEdit |
| 1127 */ |
| 1128 _onPopoverHidden: function(commitEdit) |
| 1129 { |
| 1130 this._bezierIconElement.classList.remove("bezier-editor-open"); |
| 1131 this._timeline._bezierEditor.removeEventListener(WebInspector.BezierEdit
or.Events.BezierChanged, this._bezierChanged, this); |
| 1132 if (!commitEdit) |
| 1133 this._setEasing(this._originalEasing); |
| 1134 }, |
| 1135 |
| 1136 /** |
| 1137 * @param {string} value |
| 1138 */ |
| 1139 _setEasing: function(value) |
| 1140 { |
| 1141 if (!this._node || this._animation.source().easing() === value) |
| 1142 return; |
| 1143 this._animation.setEasing(value); |
| 1144 }, |
| 1145 |
| 1146 /** |
| 1068 * @return {string} | 1147 * @return {string} |
| 1069 */ | 1148 */ |
| 1070 _color: function() | 1149 _color: function() |
| 1071 { | 1150 { |
| 1072 /** | 1151 /** |
| 1073 * @param {string} string | 1152 * @param {string} string |
| 1074 * @return {number} | 1153 * @return {number} |
| 1075 */ | 1154 */ |
| 1076 function hash(string) | 1155 function hash(string) |
| 1077 { | 1156 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1103 "Light Blue": WebInspector.Color.parse("#03A9F4"), | 1182 "Light Blue": WebInspector.Color.parse("#03A9F4"), |
| 1104 "Deep Orange": WebInspector.Color.parse("#FF5722"), | 1183 "Deep Orange": WebInspector.Color.parse("#FF5722"), |
| 1105 "Blue": WebInspector.Color.parse("#5677FC"), | 1184 "Blue": WebInspector.Color.parse("#5677FC"), |
| 1106 "Lime": WebInspector.Color.parse("#CDDC39"), | 1185 "Lime": WebInspector.Color.parse("#CDDC39"), |
| 1107 "Blue Grey": WebInspector.Color.parse("#607D8B"), | 1186 "Blue Grey": WebInspector.Color.parse("#607D8B"), |
| 1108 "Pink": WebInspector.Color.parse("#E91E63"), | 1187 "Pink": WebInspector.Color.parse("#E91E63"), |
| 1109 "Green": WebInspector.Color.parse("#0F9D58"), | 1188 "Green": WebInspector.Color.parse("#0F9D58"), |
| 1110 "Brown": WebInspector.Color.parse("#795548"), | 1189 "Brown": WebInspector.Color.parse("#795548"), |
| 1111 "Cyan": WebInspector.Color.parse("#00BCD4") | 1190 "Cyan": WebInspector.Color.parse("#00BCD4") |
| 1112 } | 1191 } |
| OLD | NEW |