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 From 15edcb5fe22793aab024c1ef7dde109b36977dd8 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Mon, 16 Jul 2012 09:20:10 -0700 Subject: Timeline: Disable drag-and-drop on subproperty keyframes. Better error handling. Fix some minor bugs. --- js/panels/Timeline/Keyframe.reel/Keyframe.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 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 a52150af..b771f6f3 100644 --- a/js/panels/Timeline/Keyframe.reel/Keyframe.js +++ b/js/panels/Timeline/Keyframe.reel/Keyframe.js @@ -119,14 +119,21 @@ var Keyframe = exports.Keyframe = Montage.create(Component, { value: function(event) { event.dataTransfer.setData('Text', 'Keyframe'); var i = 0, - tweenRepetitionLength = this.parentComponent.parentComponent.parentComponent.tweenRepetition.childComponents.length, + tweenRepetitionLength, + myTrack, myIndex = null; + if (typeof(this.parentComponent.parentComponent.parentComponent.tweenRepetition) !== "undefined") { + myTrack = this.parentComponent.parentComponent.parentComponent; + } else { + myTrack = this.parentComponent.parentComponent.parentComponent.parentComponent.parentComponent.parentComponent.parentComponent; + } + tweenRepetitionLength = myTrack.tweenRepetition.childComponents.length; for (i = 0; i < tweenRepetitionLength; i++) { - if (this.parentComponent.parentComponent.parentComponent.tweenRepetition.childComponents[i].uuid === this.parentComponent.uuid) { + if (myTrack.tweenRepetition.childComponents[i].uuid === this.parentComponent.uuid) { myIndex = i; } } - this.parentComponent.parentComponent.parentComponent.draggingIndex = myIndex; + myTrack.draggingIndex = myIndex; this.selectKeyframe(); } }, -- cgit v1.2.3 From 33e54da07d024ece1d52041d4ed2bcc28b8cbca3 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Mon, 16 Jul 2012 15:38:59 -0700 Subject: Timeline: Ameliorate slowness when adding first keyframe to an element. --- js/panels/Timeline/Keyframe.reel/Keyframe.js | 4 ++-- 1 file changed, 2 insertions(+), 2 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 b771f6f3..13902ddb 100644 --- a/js/panels/Timeline/Keyframe.reel/Keyframe.js +++ b/js/panels/Timeline/Keyframe.reel/Keyframe.js @@ -158,7 +158,7 @@ var Keyframe = exports.Keyframe = Montage.create(Component, { return; } this.isSelected=true; - this.element.style.left = (this.position - 6) + "px"; + //this.element.style.left = (this.position - 6) + "px"; Moved to draw cycle. this.application.ninja.timeline.selectedStyle = this.parentComponent.parentComponent.parentComponent.trackEditorProperty; this.parentComponent.selectTween(); } @@ -167,7 +167,7 @@ var Keyframe = exports.Keyframe = Montage.create(Component, { deselectKeyframe:{ value:function () { this.isSelected = false; - this.element.style.left = (this.position - 5) + "px"; + // this.element.style.left = (this.position - 5) + "px"; Moved to draw cycle } } // ==== End Controllers -- cgit v1.2.3