From c115fdbfca41554cb3f474e759fa6577187e93f8 Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Tue, 3 Jul 2012 11:16:42 -0700 Subject: Cleanup Keyframe.js Signed-off-by: Jonathan Duran --- js/panels/Timeline/Keyframe.reel/Keyframe.js | 71 +++++++++++++++------------- 1 file changed, 38 insertions(+), 33 deletions(-) (limited to 'js/panels/Timeline/Keyframe.reel') diff --git a/js/panels/Timeline/Keyframe.reel/Keyframe.js b/js/panels/Timeline/Keyframe.reel/Keyframe.js index f7c936f7..45a2afd3 100644 --- a/js/panels/Timeline/Keyframe.reel/Keyframe.js +++ b/js/panels/Timeline/Keyframe.reel/Keyframe.js @@ -9,6 +9,7 @@ var Component = require("montage/ui/component").Component; var Keyframe = exports.Keyframe = Montage.create(Component, { + // ==== Begin models hasTemplate:{ value: true }, @@ -42,7 +43,9 @@ var Keyframe = exports.Keyframe = Montage.create(Component, { this.needsDraw = true; } }, + // ==== End Models + // ==== Begin Draw cycle methods prepareForDraw:{ value:function(){ this.element.addEventListener("click", this, false); @@ -66,57 +69,31 @@ var Keyframe = exports.Keyframe = Montage.create(Component, { this.element.style.left = (this.position - 5) + "px"; } }, + // ==== End Draw cycle methods - deselectKeyframe:{ - value:function(){ - this.isSelected=false; - this.element.style.left = (this.position - 5) + "px"; - } - }, - - selectKeyframe:{ - value:function(){ - if(this.isSelected){ - return; - } - - if(this.parentComponent.parentComponent.parentComponent.trackType == "position"){ - var tweenID = this.parentComponent.tweenID; - var mainTrack = this.parentComponent.parentComponent.parentComponent.parentComponent.parentComponent.parentComponent.parentComponent; - mainTrack.childComponents[0].childComponents[tweenID].childComponents[0].selectKeyframe(); - return; - } - - this.isSelected=true; - this.element.style.left = (this.position - 6) + "px"; - this.application.ninja.timeline.selectedStyle = this.parentComponent.parentComponent.parentComponent.trackEditorProperty; - this.parentComponent.selectTween(); - } - }, - + // ==== Begin Event handlers handleClick:{ value:function(ev){ this.selectKeyframe(); ev.stopPropagation(); } }, - + handleMouseover: { value: function(event) { this.element.draggable = true; } }, + handleMouseout: { value: function(event) { this.element.draggable = false; } }, + handleDragstart: { value: function(event) { - //this.parentComponent.parentComponent.dragLayerID = this.layerID; event.dataTransfer.setData('Text', 'Keyframe'); - - // Get my index in my track's tween array var i = 0, tweenRepetitionLength = this.parentComponent.parentComponent.parentComponent.tweenRepetition.childComponents.length, myIndex = null; @@ -129,10 +106,38 @@ var Keyframe = exports.Keyframe = Montage.create(Component, { this.selectKeyframe(); } }, + handleDragend: { value: function(event) { this.parentComponent.isDragging = false; } - } - + }, + // ==== End Event handlers + + // === Begin Controllers + selectKeyframe:{ + value:function(){ + if(this.isSelected){ + return; + } + if(this.parentComponent.parentComponent.parentComponent.trackType == "position"){ + var tweenID = this.parentComponent.tweenID; + var mainTrack = this.parentComponent.parentComponent.parentComponent.parentComponent.parentComponent.parentComponent.parentComponent; + mainTrack.childComponents[0].childComponents[tweenID].childComponents[0].selectKeyframe(); + return; + } + this.isSelected=true; + this.element.style.left = (this.position - 6) + "px"; + this.application.ninja.timeline.selectedStyle = this.parentComponent.parentComponent.parentComponent.trackEditorProperty; + this.parentComponent.selectTween(); + } + }, + + deselectKeyframe:{ + value:function () { + this.isSelected = false; + this.element.style.left = (this.position - 5) + "px"; + } + } + // ==== End Controllers }); -- cgit v1.2.3