From f9c592ac8284cace4daed6f2ac87fe15dfad873c Mon Sep 17 00:00:00 2001 From: Kruti Shah Date: Tue, 3 Jul 2012 12:47:26 -0700 Subject: Refactoring PropertyTrack.js & Span.js Signed-off-by: Kruti Shah --- js/panels/Timeline/Span.reel/Span.js | 45 ++++++++++-------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) (limited to 'js/panels/Timeline/Span.reel/Span.js') diff --git a/js/panels/Timeline/Span.reel/Span.js b/js/panels/Timeline/Span.reel/Span.js index 3c491a53..51b9a4ce 100644 --- a/js/panels/Timeline/Span.reel/Span.js +++ b/js/panels/Timeline/Span.reel/Span.js @@ -71,9 +71,10 @@ var Span = exports.Span = Montage.create(Component, { newVal = "none"; } this._easing = newVal; - this.parentComponent.easing = this.easing; - this.parentComponent.tweenData.easing = this.easing; - this.parentComponent.setKeyframeEase(newVal); + this.parentTween = this.parentComponent; + this.parentTween.easing = this.easing; + this.parentTween.tweenData.easing = this.easing; + this.parentTween.setKeyframeEase(newVal); this.needsDraw = true; } } @@ -88,11 +89,11 @@ var Span = exports.Span = Montage.create(Component, { draw:{ value: function(){ + var containerWidth , choiceWidth; this.element.style.width = this.spanWidth + "px"; if ((this.spanWidth <= 70) && (this.spanWidth >0)) { - var containerWidth = this.spanWidth -18, - choiceWidth; + containerWidth = this.spanWidth -18 if (containerWidth < 0) { containerWidth = 0; } @@ -109,23 +110,12 @@ var Span = exports.Span = Montage.create(Component, { this.easing_choice.setAttribute("style", ""); } - // Highlight the span? if (this.isHighlighted === true) { this.element.classList.add("spanHighlight"); } else { this.element.classList.remove("spanHighlight"); } - - /* - // Hide or show the choices menu? - if (this.areChoicesVisible === true) { - this.easing_choices.style.display = "block"; - } else { - this.easing_choices.style.display = "none"; - } - */ - - // Change easing? + if (this.easing_choice.innerText !== this.easing) { this.easing_choice.innerText = this.easing; } @@ -137,23 +127,19 @@ var Span = exports.Span = Montage.create(Component, { init: { value: function() { this.easing_choice.addEventListener("click", this.handleEasingChoiceClick.bind(this), false); - //this.easing_choices.addEventListener("click", this.handleEasingChoicesClick.bind(this), false); - } }, highlightSpan:{ value: function(){ - // Class add/remove should only be done in draw cycle. - // this.element.classList.add("spanHighlight"); this.isHighlighted = true; } }, handleEasingChoiceClick: { value: function(event) { + var objPos; event.stopPropagation(); - //this.areChoicesVisible = true; this.application.ninja.timeline.easingMenu.anchor = this.easing_choice; this.application.ninja.timeline.easingMenu.currentChoice = event.currentTarget.innerText; @@ -172,7 +158,7 @@ var Span = exports.Span = Montage.create(Component, { } return objReturn; } - var objPos = findPos(event.target); + objPos = findPos(event.target); this.application.ninja.timeline.easingMenu.top = objPos.top +38 - (this.application.ninja.timeline.layout_tracks.scrollTop); this.application.ninja.timeline.easingMenu.left = objPos.left+18 - (this.application.ninja.timeline.layout_tracks.scrollLeft); this.application.ninja.timeline.easingMenu.show(); @@ -182,29 +168,22 @@ var Span = exports.Span = Montage.create(Component, { handleEasingChoicesClick: { value: function(event) { event.stopPropagation(); - - // Remove the pointer to ourselves - //this.application.ninja.timeline.currentOpenSpanMenu = false; - // Un-highlight the old choice and highlight the new choice this.application.ninja.timeline.easingMenu.popup.contentEl.querySelector(".easing-selected").classList.remove("easing-selected"); event.target.classList.add("easing-selected"); // Set the easing this.easing = event.target.dataset.ninjaEase; - this.parentComponent.easing = this.easing; - this.parentComponent.tweenData.easing = this.easing; + this.parentTween.easing = this.easing; + this.parentTween.tweenData.easing = this.easing; // Unbind the event handler this.application.ninja.timeline.easingMenu.popup.contentEl.removeEventListener("click"); - - // Hide the menu. - this.hideEasingMenu(); + this.hideEasingMenu(); } }, hideEasingMenu: { value: function() { - //this.areChoicesVisible = false; this.application.ninja.timeline.easingMenu.hide(); } } -- cgit v1.2.3