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 ++++++++++--- js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js | 12 ++++++++++++ js/panels/Timeline/Style.reel/Style.js | 2 +- js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 9 --------- js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js | 2 +- 5 files changed, 24 insertions(+), 14 deletions(-) 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(); } }, diff --git a/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js b/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js index 12e87636..9ee9b922 100644 --- a/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js +++ b/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js @@ -192,6 +192,11 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, { this.trackID = this.timelineTrack.trackID; this.animatedElement = this.timelineTrack.animatedElement; this.ninjaStylesContoller = this.application.ninja.stylesController; + + // Drag and Drop event handlers + this.element.addEventListener("dragstart", this.handleKeyframeDragstart.bind(this), false); + this.element.addEventListener("dragend", this.handleKeyframeDragstart.bind(this), false); + this.element.addEventListener("drop", this.handleKeyframeDragstart.bind(this), false); } }, @@ -206,6 +211,13 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, { /* End: Draw Cycle */ /* Begin: Event Handlers */ + + handleKeyframeDragstart: { + value: function(event) { + event.stopPropagation(); + return false; + } + }, handleClick:{ value:function (ev) { diff --git a/js/panels/Timeline/Style.reel/Style.js b/js/panels/Timeline/Style.reel/Style.js index dc159a01..930e1281 100644 --- a/js/panels/Timeline/Style.reel/Style.js +++ b/js/panels/Timeline/Style.reel/Style.js @@ -232,7 +232,7 @@ var LayerStyle = exports.LayerStyle = Montage.create(Component, { set: function(newVal) { if (this._whichView !== newVal) { if ((newVal !== "hintable") && (newVal !== "propval")) { - this.log("Error: Unknown view -"+newVal+"- requested for style.js."); + console.log("Error: Unknown view -"+newVal+"- requested for style.js."); return; } this._whichView = newVal; diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 93b4d67e..c790466c 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -979,9 +979,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.layout_tracks = this.element.querySelector(".layout-tracks"); this.layout_markers = this.element.querySelector(".layout_markers"); - // Bind the event handler for the document close events - this.eventManager.addEventListener("closeDocument", this.handleDocumentChange.bind(this), false); - // Bind drag and drop event handlers this.container_layers.addEventListener("dragstart", this.handleLayerDragStart.bind(this), false); this.container_layers.addEventListener("dragend", this.handleLayerDragEnd.bind(this), false); @@ -1628,12 +1625,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } }, - handleDocumentChange:{ - value:function () { - - } - }, - handlePlayButtonClick:{ value:function(ev){ this.application.ninja.appModel.livePreview = !this.application.ninja.appModel.livePreview; diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js index c9516d1f..e6d9165a 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js @@ -699,7 +699,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this._dragAndDropHelper.style.opacity = 0.8; this._dragAndDropHelper.style.position = "absolute"; this._dragAndDropHelper.style.top = "5px"; - this._dragAndDropHelper.style.left = "0px"; + this._dragAndDropHelper.style.left = event.target.style.left; this._dragAndDropHelper.style.zIndex = 700; this._dragAndDropHelper.classList.add("keyframeSelected"); this._dragAndDropHelper.classList.add("track-dnd-helper"); -- cgit v1.2.3