mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 08:50:06 +02:00
god damn took so long but now rebase is almost done
This commit is contained in:
parent
359878037a
commit
6e30bedd37
3 changed files with 101 additions and 9 deletions
|
@ -66,7 +66,6 @@ AnimationFactory.prototype.overrideOpacityDepth3 = function(snapShot, opacity) {
|
||||||
_.each(snapShot, function(visObj, visID) {
|
_.each(snapShot, function(visObj, visID) {
|
||||||
newSnap[visID] = this.overrideOpacityDepth2(visObj, opacity);
|
newSnap[visID] = this.overrideOpacityDepth2(visObj, opacity);
|
||||||
}, this);
|
}, this);
|
||||||
console.log(newSnap);
|
|
||||||
return newSnap;
|
return newSnap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,12 +102,22 @@ AnimationFactory.prototype.refreshTree = function(animationQueue) {
|
||||||
};
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResponse, gitEngine) {
|
AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResponse, gitEngine) {
|
||||||
|
var rebaseSteps = rebaseResponse.rebaseSteps;
|
||||||
// HIGHLIGHTING PART!!!!
|
// HIGHLIGHTING PART!!!!
|
||||||
|
|
||||||
var rebaseSteps = rebaseResponse.rebaseSteps;
|
var newVisNodes = [];
|
||||||
|
_.each(rebaseSteps, function(step) {
|
||||||
|
var visNode = step.newCommit.get('visNode');
|
||||||
|
|
||||||
_.each(rebaseSteps, function(rebaseStep) {
|
newVisNodes.push(visNode);
|
||||||
var snapshotPart = this.genFromToSnapshotAnimation(rebaseStep.beforeSnapshot, rebaseStep.afterSnapshot);
|
visNode.setOpacity(0);
|
||||||
|
visNode.setOutgoingEdgesOpacity(0);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
_.each(rebaseSteps, function(rebaseStep, index) {
|
||||||
|
var toOmit = newVisNodes.slice(0, index).concat(newVisNodes.slice(index + 1));
|
||||||
|
|
||||||
|
var snapshotPart = this.genFromToSnapshotAnimation(rebaseStep.beforeSnapshot, rebaseStep.afterSnapshot, toOmit);
|
||||||
var birthPart = this.genCommitBirthClosureFromSnapshot(rebaseStep);
|
var birthPart = this.genCommitBirthClosureFromSnapshot(rebaseStep);
|
||||||
|
|
||||||
var animation = function() {
|
var animation = function() {
|
||||||
|
@ -117,7 +126,8 @@ AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResp
|
||||||
};
|
};
|
||||||
|
|
||||||
animationQueue.add(new Animation({
|
animationQueue.add(new Animation({
|
||||||
closure: animation
|
closure: animation,
|
||||||
|
duration: GRAPHICS.defaultAnimationTime
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -126,11 +136,61 @@ AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResp
|
||||||
rebaseStep.beforeSnapshot
|
rebaseStep.beforeSnapshot
|
||||||
rebaseStep.afterSnapshot*/
|
rebaseStep.afterSnapshot*/
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
// need to delay to let bouncing finish
|
||||||
|
this.delay(animationQueue);
|
||||||
|
|
||||||
|
this.refreshTree(animationQueue);
|
||||||
};
|
};
|
||||||
|
|
||||||
AnimationFactory.prototype.genFromToSnapshotAnimation = function(beforeSnapshot, afterSnapshot) {
|
AnimationFactory.prototype.delay = function(animationQueue, time) {
|
||||||
|
time = time || GRAPHICS.defaultAnimationTime;
|
||||||
|
animationQueue.add(new Animation({
|
||||||
|
closure: function() { },
|
||||||
|
duration: time
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.genSetAllCommitOpacities = function(visNodes, opacity) {
|
||||||
|
// need to slice for closure
|
||||||
|
var nodesToAnimate = visNodes.slice(0);
|
||||||
|
|
||||||
return function() {
|
return function() {
|
||||||
console.log('from', beforeSnapshot, 'to', afterSnapshot);
|
_.each(nodesToAnimate, function(visNode) {
|
||||||
gitVisuals.animateAllFromAttrToAttr(beforeSnapshot, afterSnapshot);
|
visNode.setOpacity(opacity);
|
||||||
|
visNode.setOutgoingEdgesOpacity(opacity);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.stripObjectsFromSnapshot = function(snapShot, toOmit) {
|
||||||
|
var ids = [];
|
||||||
|
_.each(toOmit, function(obj) {
|
||||||
|
ids.push(obj.getID());
|
||||||
|
});
|
||||||
|
|
||||||
|
var newSnapshot = {};
|
||||||
|
_.each(snapShot, function(val, key) {
|
||||||
|
if (_.include(ids, key)) {
|
||||||
|
// omit
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
newSnapshot[key] = val;
|
||||||
|
}, this);
|
||||||
|
return newSnapshot;
|
||||||
|
};
|
||||||
|
|
||||||
|
AnimationFactory.prototype.genFromToSnapshotAnimation = function(beforeSnapshot, afterSnapshot, commitsToOmit) {
|
||||||
|
// we also 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);
|
||||||
|
return function() {
|
||||||
|
gitVisuals.animateAllFromAttrToAttr(before, after);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ var GRAPHICS = {
|
||||||
nodeRadius: 17,
|
nodeRadius: 17,
|
||||||
curveControlPointOffset: 50,
|
curveControlPointOffset: 50,
|
||||||
defaultEasing: 'easeInOut',
|
defaultEasing: 'easeInOut',
|
||||||
defaultAnimationTime: 300,
|
defaultAnimationTime: 1000,
|
||||||
|
|
||||||
//rectFill: '#FF3A3A',
|
//rectFill: '#FF3A3A',
|
||||||
rectFill: 'hsb(0.8816909813322127,0.7,1)',
|
rectFill: 'hsb(0.8816909813322127,0.7,1)',
|
||||||
|
|
32
src/tree.js
32
src/tree.js
|
@ -504,6 +504,14 @@ var VisNode = Backbone.Model.extend({
|
||||||
this.animateToAttr(toAttr, speed, easing);
|
this.animateToAttr(toAttr, speed, easing);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
animateToSnapshot: function(snapShot, speed, easing) {
|
||||||
|
console.log('animating to snapshot', snapShot, this.getID());
|
||||||
|
if (!snapShot[this.getID()]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.animateToAttr(snapShot[this.getID()], speed, easing);
|
||||||
|
},
|
||||||
|
|
||||||
animateToAttr: function(attr, speed, easing) {
|
animateToAttr: function(attr, speed, easing) {
|
||||||
var func = 'animate';
|
var func = 'animate';
|
||||||
if (speed == 0) {
|
if (speed == 0) {
|
||||||
|
@ -579,6 +587,12 @@ var VisNode = Backbone.Model.extend({
|
||||||
this.setOutgoingEdgesBirthPosition(this.getParentScreenCoords());
|
this.setOutgoingEdgesBirthPosition(this.getParentScreenCoords());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setOutgoingEdgesOpacity: function(opacity) {
|
||||||
|
_.each(this.get('outgoingEdges'), function(edge) {
|
||||||
|
edge.setOpacity(opacity);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
animateOutgoingEdgesToAttr: function(snapShot, speed, easing) {
|
animateOutgoingEdgesToAttr: function(snapShot, speed, easing) {
|
||||||
_.each(this.get('outgoingEdges'), function(edge) {
|
_.each(this.get('outgoingEdges'), function(edge) {
|
||||||
var attr = snapShot[edge.getID()];
|
var attr = snapShot[edge.getID()];
|
||||||
|
@ -650,6 +664,18 @@ var VisNode = Backbone.Model.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setOpacity: function(opacity) {
|
||||||
|
opacity = (opacity === undefined) ? 1 : opacity;
|
||||||
|
|
||||||
|
// set the opacity on my stuff
|
||||||
|
var keys = ['circle', 'text'];
|
||||||
|
_.each(keys, function(key) {
|
||||||
|
this.get(key).attr({
|
||||||
|
opacity: opacity
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
genGraphics: function(paper) {
|
genGraphics: function(paper) {
|
||||||
var pos = this.getScreenCoords();
|
var pos = this.getScreenCoords();
|
||||||
var textPos = this.getTextScreenCoords();
|
var textPos = this.getTextScreenCoords();
|
||||||
|
@ -768,6 +794,12 @@ var VisEdge = Backbone.Model.extend({
|
||||||
return GRAPHICS.visBranchStrokeColorNone;
|
return GRAPHICS.visBranchStrokeColorNone;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setOpacity: function(opacity) {
|
||||||
|
opacity = (opacity === undefined) ? 1 : opacity;
|
||||||
|
|
||||||
|
this.get('path').attr({opacity: opacity});
|
||||||
|
},
|
||||||
|
|
||||||
genGraphics: function(paper) {
|
genGraphics: function(paper) {
|
||||||
var pathString = this.getBezierCurve();
|
var pathString = this.getBezierCurve();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue