From 778d417d2f800b91d960849c75c0e4ee128044d1 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Wed, 9 May 2012 13:33:45 -0700 Subject: Timeline: Bug fixes for keyframe drag and drop. --- .../Timeline/TimelineTrack.reel/TimelineTrack.js | 46 +++++++++++++--------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js') diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js index 03e3b01e..1e918c6e 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js @@ -363,6 +363,17 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this._dragAndDropHelperCoords = newVal; } }, + _draggingIndex: { + value: false + }, + draggingIndex: { + get: function() { + return this._draggingIndex; + }, + set: function(newVal) { + this._draggingIndex = newVal; + } + }, _dragAndDropHelperOffset : { value: false }, @@ -864,32 +875,29 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { //this._dragAndDropHelper.style.width = window.getComputedStyle(this.container_layers, null).getPropertyValue("width"); this._dragAndDropHelper.classList.add("track-dnd-helper"); - - // Get the offset - var findYOffset = function(obj) { - var curleft = curtop = 0; - - if (obj.offsetParent) { - do { - curleft += obj.offsetLeft; - curtop += obj.offsetTop; - - } while (obj = obj.offsetParent); - } - return curtop; - } - //this._dragAndDropHelperOffset = findYOffset(this.container_layers); - if (this.draggingIndex !== (this.tweens.length -1)) { - maxPosition = this.tweenRepetition.childComponents[this.draggingIndex +1].keyFramePosition; + + if (this.draggingIndex < (this.tweens.length -1)) { + maxPosition = this.tweenRepetition.childComponents[this.draggingIndex+1].keyFramePosition; } if (this.draggingIndex > 1) { - minPosition = this.tweenRepetition.childComponents[this.draggingIndex -1].keyFramePosition; + minPosition = this.tweenRepetition.childComponents[this.draggingIndex-1].keyFramePosition; } this._keyframeMinPosition = minPosition+2; this._keyframeMaxPosition = maxPosition-9; this._appendHelper = true; this._deleteHelper = false; - this.parentComponent.parentComponent.draggingTrackId = this.trackID; + + // Get my index in the track array + var i = 0, + arrLayersLength = this.parentComponent.parentComponent.arrLayers.length, + myId = null; + for (i = 0; i < arrLayersLength; i++) { + var currUuid = this.parentComponent.parentComponent.trackRepetition.childComponents[i].uuid; + if ( currUuid === this.uuid) { + myId = i; + } + } + this.parentComponent.parentComponent.draggingTrackId = myId; this.parentComponent.parentComponent.draggingType = "keyframe"; } }, -- cgit v1.2.3