From 7bee50379c1df86bb571e0e8d6c08e24d25231f5 Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Mon, 9 Jul 2012 16:38:08 -0700 Subject: BSD License --- .../Timeline/TimelineTrack.reel/TimelineTrack.js | 95 +++++++++++----------- 1 file changed, 48 insertions(+), 47 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 11d275ce..3c97c6a8 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js @@ -1,24 +1,25 @@ /* -Copyright (c) 2012, Motorola Mobility, Inc +Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved. -BSD License. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of Motorola Mobility nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Motorola Mobility LLC nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -69,7 +70,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { positionPropertyTrack:{ value:null }, - + _isFirstDraw: { value: true }, @@ -96,7 +97,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this.trackData.isVisible = value; } }, - + _stageElement: { value: null }, @@ -174,7 +175,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { } } }, - + _arrStyleTracks : { value: [] }, @@ -200,7 +201,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this._styleTracksRepetition = newVal; } }, - + /* Position Property Tracks */ _arrPositionTracks : { value: [] @@ -213,7 +214,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { set: function(newVal) { this._arrPositionTracks = newVal; this.trackData.arrPositionTracks = newVal; - + } }, _positionTracksRepetition: { @@ -495,7 +496,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { } } }, - + _setDataTimestamp : { value: false }, @@ -533,7 +534,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { tempData.bypassAnimation = this.bypassAnimation; tempData.trackID = this.layerID; tempData.tweens = this.tweens; - tempData.animatedElement = this.animatedElement; + tempData.animatedElement = this.animatedElement; tempData.arrStyleTracks = this.arrStyleTracks; tempData.arrPositionTracks = this.arrPositionTracks; tempData.isTrackAnimated = this.isTrackAnimated; @@ -549,7 +550,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this.trackData = tempData; } }, - + // Data binding observation point and trigger method _bindingPoint : { value : {} @@ -565,7 +566,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { } } }, - + triggerOutgoingBinding : { value: function() { this.trackData.triggerBinding = !this.trackData.triggerBinding; @@ -578,8 +579,8 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this.ninjaStylesContoller = this.application.ninja.stylesController; this.element.addEventListener("click", this, false); this.eventManager.addEventListener("tlZoomSlider", this, false); - - // Drag and Drop event handlers + + // Drag and Drop event handlers //this.element.addEventListener("dragover", this.handleKeyframeDragover.bind(this), false); this.element.addEventListener("dragstart", this.handleKeyframeDragstart.bind(this), false); this.element.addEventListener("dragend", this.handleKeyframeDragend.bind(this), false); @@ -647,9 +648,9 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { } } } - + if (this._isFirstDraw === true) { - + if (this.isMainCollapsed === false) { this._mainCollapser.myContent.style.height = "auto"; this._mainCollapser.myContent.classList.remove(this._mainCollapser.collapsedClass); @@ -672,19 +673,19 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { } this._isFirstDraw = false; } - + } }, handleTlZoomSlider: { value: function(event) { - + var currentMilliSecPerPixel , currentMilliSec , clickPos,thingToPush; var i = 0, tweensLength = this.tweens.length; for (i = 0; i < tweensLength; i++) { - + if (i === 0) { // Exception: 0th item does not depend on anything // TODO: If 0th tween is draggable, this will need to be fixed. @@ -692,7 +693,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this.tweens[i].tweenData.spanPosition=0; this.tweens[i].tweenData.keyFramePosition=0; this.tweens[i].tweenData.keyFrameMillisec=0; - + } else { var prevKeyFramePosition = this.tweens[i - 1].tweenData.keyFramePosition, myObj = {}, @@ -769,7 +770,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { handleNewTween:{ value:function (ev) { - + if (ev.offsetX > this.tweens[this.tweens.length - 1].tweenData.keyFramePosition) { var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); this.application.ninja.timeline.selectLayer(selectedIndex, false); @@ -906,8 +907,8 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { value:function (position) { var i, j, nextComponentIndex, tweensLength = this.tweens.length-1, - prevTween, - nextTween, + prevTween, + nextTween, splitTweenIndex; // Search through the tweens and find the pair whose keyframes bracket position. @@ -915,7 +916,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { prevTween = this.tweens[i].tweenData.keyFramePosition; nextTween = this.tweens[i+1].tweenData.keyFramePosition; if(position > prevTween && position < nextTween) { - + // We will insert a new tween at this index splitTweenIndex = i+1; @@ -924,7 +925,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this.tweens[i+1].spanPosition = position; this.tweens[i+1].tweenData.spanWidth = this.tweens[i+1].tweenData.keyFramePosition - position; this.tweens[i+1].spanWidth = this.tweens[i+1].keyFramePosition - position; - + // You'd think that would be enough to make the component associated with that part of the array redraw, wouldn't you? // Turns out we have to manually poke the desired childComponent in the repetition to register its new changes. // So we have to get the index of the actual componentin the repetition, which may not match our iteration index. @@ -949,15 +950,15 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { newTweenToInsert.tweenData.tweenedProperties["width"] = this.animatedElement.offsetWidth + "px"; newTweenToInsert.tweenData.tweenedProperties["height"] = this.animatedElement.offsetHeight + "px"; this.tweens.splice(splitTweenIndex, 0, newTweenToInsert); - + // We are done, so end the loop. i = tweensLength; } } - + // We've made a change, so set the needsSave flag this.application.ninja.currentDocument.model.needsSave = true; - + // Our tween IDs are now all messed up. Fix them. for (i = 0; i <= tweensLength+1; i++) { this.tweens[i].tweenID = i; @@ -1150,7 +1151,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { createPositionTracks:{ value:function(){ // create track objects for position and transform tracks and push into arrays - + // ... but only do it if we haven't already. if (this.arrPositionTracks.length > 0) { return; @@ -1241,20 +1242,20 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { return returnVal; } }, - + // Drag and drop event handlers handleKeyframeDragstart : { value: function(event) { - var dragIcon = document.createElement("img"), + var dragIcon = document.createElement("img"), minPosition = 0, maxPosition = 100000000000; - + event.dataTransfer.effectAllowed = 'move'; event.dataTransfer.setData('Text', this.identifier); dragIcon.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAA1JREFUGFdj+P//PwMACPwC/ohfBuAAAAAASUVORK5CYII=" dragIcon.width = 1; event.dataTransfer.setDragImage(dragIcon, 0, 0); - + // Clone the element we're dragging this._dragAndDropHelper = event.target.cloneNode(true); this._dragAndDropHelper.style.opacity = 0.8; @@ -1263,10 +1264,10 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this._dragAndDropHelper.style.left = "0px"; this._dragAndDropHelper.style.zIndex = 700; this._dragAndDropHelper.classList.add("keyframeSelected"); - + //this._dragAndDropHelper.style.width = window.getComputedStyle(this.container_layers, null).getPropertyValue("width"); this._dragAndDropHelper.classList.add("track-dnd-helper"); - + if (this.draggingIndex < (this.tweens.length -1)) { maxPosition = this.tweenRepetition.childComponents[this.draggingIndex+1].keyFramePosition; } @@ -1277,7 +1278,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { this._keyframeMaxPosition = maxPosition-9; this._appendHelper = true; this._deleteHelper = false; - + // Get my index in the track array var i = 0, arrLayersLength = this.parentComponent.parentComponent.arrLayers.length, @@ -1299,11 +1300,11 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { } this._deleteHelper = true; this.needsDraw = true; - + } }, - - + + /* Begin: Logging routines */ _boolDebug: { enumerable: false, -- cgit v1.2.3