diff --git a/src/animationFactory.js b/src/animationFactory.js index 6089da64..352d8051 100644 --- a/src/animationFactory.js +++ b/src/animationFactory.js @@ -114,10 +114,16 @@ AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResp visNode.setOutgoingEdgesOpacity(0); }, this); + var previousVisNodes = []; _.each(rebaseSteps, function(rebaseStep, index) { - var toOmit = newVisNodes.slice(0, index).concat(newVisNodes.slice(index + 1)); + var toOmit = newVisNodes.slice(index + 1); - var snapshotPart = this.genFromToSnapshotAnimation(rebaseStep.beforeSnapshot, rebaseStep.afterSnapshot, toOmit); + var snapshotPart = this.genFromToSnapshotAnimation( + rebaseStep.beforeSnapshot, + rebaseStep.afterSnapshot, + toOmit, + previousVisNodes + ); var birthPart = this.genCommitBirthClosureFromSnapshot(rebaseStep); var animation = function() { @@ -127,7 +133,7 @@ AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResp animationQueue.add(new Animation({ closure: animation, - duration: GRAPHICS.defaultAnimationTime + duration: GRAPHICS.defaultAnimationTime * 2 })); /* @@ -135,6 +141,7 @@ AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResp rebaseStep.newCommit rebaseStep.beforeSnapshot rebaseStep.afterSnapshot*/ + previousVisNodes.push(rebaseStep.newCommit.get('visNode')); }, this); // need to delay to let bouncing finish @@ -180,17 +187,37 @@ AnimationFactory.prototype.stripObjectsFromSnapshot = function(snapShot, toOmit) return newSnapshot; }; -AnimationFactory.prototype.genFromToSnapshotAnimation = function(beforeSnapshot, afterSnapshot, commitsToOmit) { - // we also want to omit the commit outgoing edges +AnimationFactory.prototype.genFromToSnapshotAnimation = function( + beforeSnapshot, + afterSnapshot, + commitsToOmit, + commitsToFixOpacity) { + + // we want to omit the commit outgoing edges var toOmit = []; _.each(commitsToOmit, function(visNode) { toOmit.push(visNode); toOmit = toOmit.concat(visNode.get('outgoingEdges')); }); - before = this.stripObjectsFromSnapshot(beforeSnapshot, toOmit); - after = this.stripObjectsFromSnapshot(afterSnapshot, toOmit); + var fixOpacity = function(obj) { + if (!obj) { return; } + _.each(obj, function(attr, partName) { + obj[partName].opacity = 1; + }); + }; + + // HORRIBLE loop to fix opacities all throughout the snapshot + _.each([beforeSnapshot, afterSnapshot], function(snapShot) { + _.each(commitsToFixOpacity, function(visNode) { + fixOpacity(snapShot[visNode.getID()]); + _.each(visNode.get('outgoingEdges'), function(visEdge) { + fixOpacity(snapShot[visEdge.getID()]); + }); + }); + }); + return function() { - gitVisuals.animateAllFromAttrToAttr(before, after); + gitVisuals.animateAllFromAttrToAttr(beforeSnapshot, afterSnapshot, toOmit); }; }; diff --git a/src/constants.js b/src/constants.js index 8d23fe99..6c5cdd3c 100644 --- a/src/constants.js +++ b/src/constants.js @@ -19,7 +19,7 @@ var GRAPHICS = { nodeRadius: 17, curveControlPointOffset: 50, defaultEasing: 'easeInOut', - defaultAnimationTime: 1000, + defaultAnimationTime: 400, //rectFill: '#FF3A3A', rectFill: 'hsb(0.8816909813322127,0.7,1)', diff --git a/src/visuals.js b/src/visuals.js index 0a7c934c..794029c4 100644 --- a/src/visuals.js +++ b/src/visuals.js @@ -64,11 +64,15 @@ GitVisuals.prototype.toScreenCoords = function(pos) { }; }; -GitVisuals.prototype.animateAllFromAttrToAttr = function(fromSnapshot, toSnapshot) { +GitVisuals.prototype.animateAllFromAttrToAttr = function(fromSnapshot, toSnapshot, idsToOmit) { var animate = function(obj) { var id = obj.getID(); + if (_.include(idsToOmit, id)) { + return; + } + if (!fromSnapshot[id] || !toSnapshot[id]) { - console.warn('this obj doesnt exist yet', id); + // its actually ok it doesnt exist yet return; } obj.animateFromAttrToAttr(fromSnapshot[id], toSnapshot[id]); diff --git a/todo.txt b/todo.txt index b71152b8..239d27b7 100644 --- a/todo.txt +++ b/todo.txt @@ -8,25 +8,17 @@ animation factory? stuff like: Big Graphic things: ~~~~~~~~~~~~~~~~~~~~~~~~~ -- When you are rebasing and you hit the bottom, all the nodes go in the wrong spot... - -- animateSnapshotFromTo(), then animate specific nodes - Medium things: ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Rebuilding trees from a JSON snapshot / blob. this should be easy... i think. if we remove the need for parents -- sizing on visedge arrowheads, also fill most likely - Small things to implement: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Minor Bugs to fix: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Big Bugs to fix: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - resolve core ID from alt Id's (C4''' becomes C4), and then skip those commits when rebasing. big