mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 00:18:56 +02:00
never thought i would see the DAYgit pushgit push! rebase animation fully working for all edge cases
This commit is contained in:
parent
6e30bedd37
commit
be2a5bf35b
4 changed files with 42 additions and 19 deletions
|
@ -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);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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)',
|
||||
|
|
|
@ -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]);
|
||||
|
|
8
todo.txt
8
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue