aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/Span.reel/Span.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/Span.reel/Span.js')
-rw-r--r--js/panels/Timeline/Span.reel/Span.js127
1 files changed, 124 insertions, 3 deletions
diff --git a/js/panels/Timeline/Span.reel/Span.js b/js/panels/Timeline/Span.reel/Span.js
index bfa6aab8..1ab3455c 100644
--- a/js/panels/Timeline/Span.reel/Span.js
+++ b/js/panels/Timeline/Span.reel/Span.js
@@ -13,10 +13,10 @@ var Span = exports.Span = Montage.create(Component, {
13 value: true 13 value: true
14 }, 14 },
15 15
16 // BEGIN: Models
16 _spanWidth:{ 17 _spanWidth:{
17 value:0 18 value:0
18 }, 19 },
19
20 spanWidth:{ 20 spanWidth:{
21 serializable:true, 21 serializable:true,
22 get:function () { 22 get:function () {
@@ -27,16 +27,137 @@ var Span = exports.Span = Montage.create(Component, {
27 this.needsDraw = true; 27 this.needsDraw = true;
28 } 28 }
29 }, 29 },
30 30
31 _isHighlighted: {
32 value: false
33 },
34 isHighlighted: {
35 get: function() {
36 return this._isHighlighted;
37 },
38 set: function(newVal) {
39 if (newVal !== this._isHighlighted) {
40 this._isHighlighted = newVal;
41 this.needsDraw = true;
42 }
43 }
44 },
45
46 _areChoicesVisible: {
47 value: false
48 },
49 areChoicesVisible: {
50 get: function() {
51 return this._areChoicesVisible;
52 },
53 set: function(newVal) {
54 if (newVal !== this._areChoicesVisible) {
55 this._areChoicesVisible = newVal;
56 this.needsDraw = true;
57 }
58 }
59 },
60
61 _easing: {
62 value: "ease-in"
63 },
64 easing: {
65 get: function() {
66 return this._easing;
67 },
68 set: function(newVal) {
69 if (newVal !== this._easing) {
70 this._easing = newVal;
71 this.parentComponent.setKeyframeEase(newVal);
72 this.needsDraw = true;
73 }
74 }
75 },
76
77 // BEGIN: draw cycle
78 prepareForDraw: {
79 value: function() {
80 this.init();
81 }
82 },
83
31 draw:{ 84 draw:{
32 value: function(){ 85 value: function(){
86
33 this.element.style.width = this.spanWidth + "px"; 87 this.element.style.width = this.spanWidth + "px";
88
89 if ((this.spanWidth <= 70) && (this.spanWidth >0)) {
90 var containerWidth = this.spanWidth -18,
91 choiceWidth;
92 if (containerWidth < 0) {
93 containerWidth = 0;
94 }
95 choiceWidth = containerWidth -3;
96 if (choiceWidth < 0) {
97 choiceWidth = 0;
98 }
99 this.container_easing.style.width = containerWidth + "px";
100 this.easing_choice.style.width = choiceWidth + "px";
101 this.easing_choice.style.overflow = "hidden";
102 }
103 if (this.spanWidth > 70) {
104 this.container_easing.setAttribute("style", "");
105 this.easing_choice.setAttribute("style", "");
106 }
107
108 // Highlight the span?
109 if (this.isHighlighted === true) {
110 this.element.classList.add("spanHighlight");
111 } else {
112 this.element.classList.remove("spanHighlight");
113 }
114
115 // Hide or show the choices menu?
116 if (this.areChoicesVisible === true) {
117 this.easing_choices.style.display = "block";
118 } else {
119 this.easing_choices.style.display = "none";
120 }
121
122 // Change easing?
123 if (this.easing_choice.innerText !== this.easing) {
124 this.easing_choice.innerText = this.easing;
125 }
126
34 } 127 }
35 }, 128 },
36 129
130 // BEGIN: Controllers
131 init: {
132 value: function() {
133 this.easing_choice.addEventListener("click", this.handleEasingChoiceClick.bind(this), false);
134 this.easing_choices.addEventListener("click", this.handleEasingChoicesClick.bind(this), false);
135
136 }
137 },
138
37 highlightSpan:{ 139 highlightSpan:{
38 value: function(){ 140 value: function(){
39 this.element.classList.add("spanHighlight"); 141 // Class add/remove should only be done in draw cycle.
142 // this.element.classList.add("spanHighlight");
143 this.isHighlighted = true;
40 } 144 }
145 },
146
147 handleEasingChoiceClick: {
148 value: function(event) {
149 this.areChoicesVisible = true;
150 }
151 },
152 handleEasingChoicesClick: {
153 value: function(event) {
154
155 this.easing_choices.querySelector(".easing-selected").classList.remove("easing-selected");
156 event.target.classList.add("easing-selected");
157 this.easing = event.target.dataset.ninjaEase;
158
159 // Which element was just
160 this.areChoicesVisible = false;
161 }
41 } 162 }
42}); 163});