aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js')
-rw-r--r--js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js115
1 files changed, 98 insertions, 17 deletions
diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
index 1e918c6e..83aef230 100644
--- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
+++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
@@ -223,10 +223,10 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
223 223
224 tweenRepetition:{ 224 tweenRepetition:{
225 get:function () { 225 get:function () {
226 return this._spanRepetition; 226 return this._tweenRepetition;
227 }, 227 },
228 set:function (newVal) { 228 set:function (newVal) {
229 this._spanRepetition = newVal; 229 this._tweenRepetition = newVal;
230 } 230 }
231 }, 231 },
232 232
@@ -412,7 +412,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
412 this.bypassAnimation = this.trackData.bypassAnimation; 412 this.bypassAnimation = this.trackData.bypassAnimation;
413 this.trackID = this.trackData.layerID; 413 this.trackID = this.trackData.layerID;
414 this.tweens = this.trackData.tweens; 414 this.tweens = this.trackData.tweens;
415 this.animatedElement = this.trackData.animatedElement; // unneeded with one element per layer restriction 415 this.animatedElement = this.trackData.animatedElement;
416 this.arrStyleTracks = this.trackData.arrStyleTracks; 416 this.arrStyleTracks = this.trackData.arrStyleTracks;
417 this.isTrackAnimated = this.trackData.isTrackAnimated; 417 this.isTrackAnimated = this.trackData.isTrackAnimated;
418 this.trackDuration = this.trackData.trackDuration; 418 this.trackDuration = this.trackData.trackDuration;
@@ -520,11 +520,6 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
520 } 520 }
521 } 521 }
522 } 522 }
523
524
525
526
527
528 523
529 } 524 }
530 }, 525 },
@@ -537,7 +532,6 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
537 if (selectedIndex !== false) { 532 if (selectedIndex !== false) {
538 if (!this.application.ninja.timeline.arrLayers[selectedIndex].layerData.created) { 533 if (!this.application.ninja.timeline.arrLayers[selectedIndex].layerData.created) {
539 this.retrieveStoredTweens(); 534 this.retrieveStoredTweens();
540
541 } 535 }
542 } 536 }
543 } 537 }
@@ -628,6 +622,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
628 this.updateKeyframeRule(); 622 this.updateKeyframeRule();
629 } 623 }
630 } else { 624 } else {
625 // TEMP error check
631 console.log("There must be exactly one element in an animated layer."); 626 console.log("There must be exactly one element in an animated layer.");
632 } 627 }
633 } 628 }
@@ -641,6 +636,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
641 this.application.ninja.timeline.selectLayer(selectedIndex, false); 636 this.application.ninja.timeline.selectLayer(selectedIndex, false);
642 this.insertTween(ev.offsetX); 637 this.insertTween(ev.offsetX);
643 } else { 638 } else {
639 console.log(ev.target);
644 this.splitTween(ev); 640 this.splitTween(ev);
645 } 641 }
646 } 642 }
@@ -649,7 +645,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
649 insertTween:{ 645 insertTween:{
650 value:function (clickPos) { 646 value:function (clickPos) {
651 var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); 647 var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID);
652 this.application.ninja.timeline.selectLayer(selectedIndex, true); 648 this.application.ninja.timeline.selectLayer(selectedIndex, true);
653 649
654 var currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); 650 var currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80);
655 var currentMillisec = currentMillisecPerPixel * clickPos; 651 var currentMillisec = currentMillisecPerPixel * clickPos;
@@ -695,7 +691,42 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
695 691
696 splitTween:{ 692 splitTween:{
697 value:function (ev) { 693 value:function (ev) {
698 console.log("Splitting an existing span with a new keyframe is not yet supported."); 694 var clickPos = ev.target.parentElement.offsetLeft + ev.offsetX;
695 var i;
696 var tweensLength = this.tweens.length-1;
697 var prevTween, nextTween, splitTweenIndex;
698 for(i=0; i<tweensLength; i++){
699 prevTween = this.tweens[i].tweenData.keyFramePosition;
700 nextTween = this.tweens[i+1].tweenData.keyFramePosition;
701 if(clickPos > prevTween && clickPos < nextTween){
702 //console.log(clickPos + " found on tween: "+ this.tweens[i+1].tweenData.tweenID);
703 splitTweenIndex = this.tweens[i+1].tweenData.tweenID;
704 this.tweens[i+1].tweenData.spanWidth = this.tweens[i+1].tweenData.keyFramePosition - clickPos;
705 this.tweens[i+1].tweenData.spanPosition = ev.target.parentElement.offsetLeft + ev.offsetX;
706 if (ev.target.className != "tween-span") {
707 // don't set styles on timeline track if event is coming from the track
708 } else {
709 ev.target.style.width = this.tweens[i + 1].tweenData.spanWidth + "px";
710 ev.target.parentElement.style.left = clickPos + "px";
711 ev.target.parentElement.children[1].style.left = (this.tweens[i + 1].tweenData.spanWidth - 3) + "px";
712 }
713 var newTweenToInsert = {};
714 newTweenToInsert.tweenData = {};
715 newTweenToInsert.tweenData.spanWidth = clickPos - prevTween;
716 newTweenToInsert.tweenData.keyFramePosition = clickPos;
717 newTweenToInsert.tweenData.keyFrameMillisec = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80) * clickPos;
718 newTweenToInsert.tweenData.tweenID = splitTweenIndex - 1;
719 newTweenToInsert.tweenData.spanPosition = clickPos - newTweenToInsert.tweenData.spanWidth;
720 newTweenToInsert.tweenData.tweenedProperties = [];
721 newTweenToInsert.tweenData.tweenedProperties["top"] = this.animatedElement.offsetTop;
722 newTweenToInsert.tweenData.tweenedProperties["left"] = this.animatedElement.offsetLeft;
723 newTweenToInsert.tweenData.tweenedProperties["width"] = this.animatedElement.offsetWidth;
724 newTweenToInsert.tweenData.tweenedProperties["height"] = this.animatedElement.offsetHeight;
725 this.tweens.splice(splitTweenIndex, 0, newTweenToInsert);
726 break;
727 }
728 }
729 this.application.ninja.documentController.activeDocument.needsSave = true;
699 } 730 }
700 }, 731 },
701 732
@@ -770,7 +801,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
770 this.tweens[0].tweenData.tweenedProperties["top"] = this.animatedElement.offsetTop; 801 this.tweens[0].tweenData.tweenedProperties["top"] = this.animatedElement.offsetTop;
771 this.tweens[0].tweenData.tweenedProperties["left"] = this.animatedElement.offsetLeft; 802 this.tweens[0].tweenData.tweenedProperties["left"] = this.animatedElement.offsetLeft;
772 var animationDuration = Math.round(this.trackDuration / 1000) + "s"; 803 var animationDuration = Math.round(this.trackDuration / 1000) + "s";
773 this.animationName = "animation_" + this.animatedElement.classList[0]; 804 this.animationName = this.animatedElement.classList[0] + "_PositionSize";
774 this.ninjaStylesContoller.setElementStyle(this.animatedElement, "-webkit-animation-name", this.animationName); 805 this.ninjaStylesContoller.setElementStyle(this.animatedElement, "-webkit-animation-name", this.animationName);
775 this.ninjaStylesContoller.setElementStyle(this.animatedElement, "-webkit-animation-duration", animationDuration); 806 this.ninjaStylesContoller.setElementStyle(this.animatedElement, "-webkit-animation-duration", animationDuration);
776 this.ninjaStylesContoller.setElementStyle(this.animatedElement, "-webkit-animation-iteration-count", 1); 807 this.ninjaStylesContoller.setElementStyle(this.animatedElement, "-webkit-animation-iteration-count", 1);
@@ -815,13 +846,51 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, {
815 // Init and event handler for layer expand/collapse 846 // Init and event handler for layer expand/collapse
816 init:{ 847 init:{
817 value:function () { 848 value:function () {
818 849 this.createPositionTracks();
819 this.arrPositionTracks = [0, 1];
820 this.arrTransformTracks = [0, 1, 2, 3, 4];
821
822 // Register event handler for layer events. 850 // Register event handler for layer events.
823 defaultEventManager.addEventListener("layerEvent", this, false); 851 defaultEventManager.addEventListener("layerEvent", this, false);
852 }
853 },
824 854
855 createPositionTracks:{
856 value:function(){
857 // create track objects for position and transform tracks and push into arrays
858
859 // create 'top' track
860 var newTopTrack = {};
861 newTopTrack.propTrackData = {};
862 newTopTrack.propTrackData.propTweens = [];
863 newTopTrack.propTrackData.styleIndex = 0;
864 newTopTrack.propTrackData.trackType = "position";
865 newTopTrack.propTrackData.trackEditorProperty = "top";
866 this.arrPositionTracks.push(newTopTrack);
867
868 // create 'left' track
869 var newLeftTrack = {};
870 newLeftTrack.propTrackData = {};
871 newLeftTrack.propTrackData.propTweens = [];
872 newLeftTrack.propTrackData.styleIndex = 1;
873 newLeftTrack.propTrackData.trackType = "position";
874 newLeftTrack.propTrackData.trackEditorProperty = "left";
875 this.arrPositionTracks.push(newLeftTrack);
876
877 // create 'width' track
878 var newWidthTrack = {};
879 newWidthTrack.propTrackData = {};
880 newWidthTrack.propTrackData.propTweens = [];
881 newWidthTrack.propTrackData.styleIndex = 2;
882 newWidthTrack.propTrackData.trackType = "position";
883 newWidthTrack.propTrackData.trackEditorProperty = "width";
884 this.arrPositionTracks.push(newWidthTrack);
885
886 // create 'height' track
887 var newHeightTrack = {};
888 newHeightTrack.propTrackData = {};
889 newHeightTrack.propTrackData.propTweens = [];
890 newHeightTrack.propTrackData.styleIndex = 3;
891 newHeightTrack.propTrackData.trackType = "position";
892 newHeightTrack.propTrackData.trackEditorProperty = "height";
893 this.arrPositionTracks.push(newHeightTrack);