mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-01 18:24:28 +02:00
snapshots done
This commit is contained in:
parent
b22f439a43
commit
b106e22ac3
3 changed files with 102 additions and 39 deletions
|
@ -46,6 +46,7 @@ AnimationFactory.prototype.genCommitBirthAnimationInSequence = function(animatio
|
||||||
|
|
||||||
var time = GRAPHICS.defaultAnimationTime * 1.0;
|
var time = GRAPHICS.defaultAnimationTime * 1.0;
|
||||||
var bounceTime = time * 2.0;
|
var bounceTime = time * 2.0;
|
||||||
|
|
||||||
var toHide = commits.slice(index + 1);
|
var toHide = commits.slice(index + 1);
|
||||||
var visNode = commits[index].get('visNode');
|
var visNode = commits[index].get('visNode');
|
||||||
|
|
||||||
|
|
97
src/tree.js
97
src/tree.js
|
@ -31,6 +31,10 @@ var VisBranch = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getID: function() {
|
||||||
|
return this.get('branch').get('id');
|
||||||
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.validateAtInit();
|
this.validateAtInit();
|
||||||
if (this.get('branch').get('id') == 'HEAD') {
|
if (this.get('branch').get('id') == 'HEAD') {
|
||||||
|
@ -283,35 +287,49 @@ var VisBranch = Backbone.Model.extend({
|
||||||
return 1;
|
return 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
animateUpdatedPos: function(speed, easing) {
|
getAttributes: function() {
|
||||||
var s = speed !== undefined ? speed : this.get('animationSpeed');
|
|
||||||
var e = easing || this.get('animationEasing');
|
|
||||||
var nonTextOpacity = this.getNonTextOpacity();
|
var nonTextOpacity = this.getNonTextOpacity();
|
||||||
var textOpacity = this.getTextOpacity();
|
var textOpacity = this.getTextOpacity();
|
||||||
|
|
||||||
this.updateName();
|
this.updateName();
|
||||||
|
|
||||||
var textPos = this.getTextPosition();
|
var textPos = this.getTextPosition();
|
||||||
this.get('text').stop().animate({
|
var rectPos = this.getRectPosition();
|
||||||
|
var rectSize = this.getRectSize();
|
||||||
|
|
||||||
|
var arrowPath = this.getArrowPath();
|
||||||
|
|
||||||
|
return {
|
||||||
|
text: {
|
||||||
x: textPos.x,
|
x: textPos.x,
|
||||||
y: textPos.y,
|
y: textPos.y,
|
||||||
opacity: textOpacity
|
opacity: textOpacity
|
||||||
}, s, e);
|
},
|
||||||
|
rect: {
|
||||||
var rectPos = this.getRectPosition();
|
|
||||||
var rectSize = this.getRectSize();
|
|
||||||
this.get('rect').stop().animate({
|
|
||||||
x: rectPos.x,
|
x: rectPos.x,
|
||||||
y: rectPos.y,
|
y: rectPos.y,
|
||||||
width: rectSize.w,
|
width: rectSize.w,
|
||||||
height: rectSize.h,
|
height: rectSize.h,
|
||||||
opacity: nonTextOpacity,
|
opacity: nonTextOpacity
|
||||||
}, s, e);
|
},
|
||||||
|
arrow: {
|
||||||
var arrowPath = this.getArrowPath();
|
|
||||||
this.get('arrow').stop().animate({
|
|
||||||
path: arrowPath,
|
path: arrowPath,
|
||||||
opacity: nonTextOpacity
|
opacity: nonTextOpacity
|
||||||
}, s, e);
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
animateUpdatedPos: function(speed, easing) {
|
||||||
|
var attr = this.getAttributes();
|
||||||
|
this.animateFromAttributes(speed, easing, attr);
|
||||||
|
},
|
||||||
|
|
||||||
|
animateFromAttributes: function(speed, easing, attr) {
|
||||||
|
var s = speed !== undefined ? speed : this.get('animationSpeed');
|
||||||
|
var e = easing || this.get('animationEasing');
|
||||||
|
|
||||||
|
this.get('text').stop().animate(attr.text, s, e);
|
||||||
|
this.get('rect').stop().animate(attr.rect, s, e);
|
||||||
|
this.get('arrow').stop().animate(attr.arrow, s, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -390,16 +408,26 @@ var VisNode = Backbone.Model.extend({
|
||||||
return map[stat];
|
return map[stat];
|
||||||
},
|
},
|
||||||
|
|
||||||
animateUpdatedPosition: function(speed, easing) {
|
getAttributes: function() {
|
||||||
var pos = this.getScreenCoords();
|
var pos = this.getScreenCoords();
|
||||||
var opacity = this.getOpacity();
|
return {
|
||||||
|
circle: {
|
||||||
this.get('circle').stop().animate({
|
|
||||||
cx: pos.x,
|
cx: pos.x,
|
||||||
cy: pos.y,
|
cy: pos.y,
|
||||||
opacity: opacity,
|
opacity: this.getOpacity(),
|
||||||
r: this.getRadius()
|
r: this.getRadius()
|
||||||
|
}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
animateUpdatedPosition: function(speed, easing) {
|
||||||
|
var attr = this.getAttributes();
|
||||||
|
this.animateFromAttr(speed, easing, attr);
|
||||||
|
},
|
||||||
|
|
||||||
|
animateFromAttr: function(speed, easing, attr) {
|
||||||
|
this.get('circle').stop().animate(
|
||||||
|
attr.circle,
|
||||||
speed !== undefined ? speed : this.get('animationSpeed'),
|
speed !== undefined ? speed : this.get('animationSpeed'),
|
||||||
easing || this.get('animationEasing')
|
easing || this.get('animationEasing')
|
||||||
);
|
);
|
||||||
|
@ -484,6 +512,10 @@ var VisEdge = Backbone.Model.extend({
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getID: function() {
|
||||||
|
return this.get('tail').get('id') + '.' + this.get('head').get('id');
|
||||||
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.validateAtInit();
|
this.validateAtInit();
|
||||||
|
|
||||||
|
@ -566,19 +598,26 @@ var VisEdge = Backbone.Model.extend({
|
||||||
return map[stat];
|
return map[stat];
|
||||||
},
|
},
|
||||||
|
|
||||||
animateUpdatedPath: function(speed, easing) {
|
getAttributes: function() {
|
||||||
var newPath = this.getBezierCurve();
|
var newPath = this.getBezierCurve();
|
||||||
this.animateUpdatedPathFromPath(newPath, speed, easing);
|
|
||||||
},
|
|
||||||
|
|
||||||
animateUpdatedPathFromPath: function(newPath, speed, easing) {
|
|
||||||
var opacity = this.getOpacity();
|
var opacity = this.getOpacity();
|
||||||
|
return {
|
||||||
this.get('path').toBack();
|
path: {
|
||||||
this.get('path').stop().animate({
|
|
||||||
path: newPath,
|
path: newPath,
|
||||||
opacity: opacity
|
opacity: opacity
|
||||||
|
}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
animateUpdatedPath: function(speed, easing) {
|
||||||
|
var attr = this.getAttributes();
|
||||||
|
this.animateFromAttributes(speed, easing, attr);
|
||||||
|
},
|
||||||
|
|
||||||
|
animateFromAttributes: function(speed, easing, attr) {
|
||||||
|
this.get('path').toBack();
|
||||||
|
this.get('path').stop().animate(
|
||||||
|
attr.path,
|
||||||
speed !== undefined ? speed : this.get('animationSpeed'),
|
speed !== undefined ? speed : this.get('animationSpeed'),
|
||||||
easing || this.get('animationEasing')
|
easing || this.get('animationEasing')
|
||||||
);
|
);
|
||||||
|
|
|
@ -81,16 +81,34 @@ GitVisuals.prototype.toScreenCoords = function(pos) {
|
||||||
|
|
||||||
**************************************/
|
**************************************/
|
||||||
|
|
||||||
|
GitVisuals.prototype.genSnapshot = function() {
|
||||||
|
this.fullCalc();
|
||||||
|
|
||||||
|
var snapshot = {};
|
||||||
|
_.each(this.visNodeMap, function(visNode) {
|
||||||
|
snapshot[visNode.get('id')] = visNode.getAttributes();
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.visBranchCollection.each(function(visBranch) {
|
||||||
|
snapshot[visBranch.getID()] = visBranch.getAttributes();
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.edgeCollection.each(function(visEdge) {
|
||||||
|
snapshot[visEdge.getID()] = visEdge.getAttributes();
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
return snapshot;
|
||||||
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.refreshTree = function(speed) {
|
GitVisuals.prototype.refreshTree = function(speed) {
|
||||||
// this method can only be called after graphics are rendered
|
// this method can only be called after graphics are rendered
|
||||||
this.calcTreeCoords();
|
this.fullCalc();
|
||||||
this.calcGraphicsCoords();
|
|
||||||
|
|
||||||
this.animateAll(speed);
|
this.animateAll(speed);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.refreshTreeHarsh = function() {
|
GitVisuals.prototype.refreshTreeHarsh = function() {
|
||||||
this.calcTreeCoords();
|
this.fullCalc();
|
||||||
|
|
||||||
this.animateAll(0);
|
this.animateAll(0);
|
||||||
};
|
};
|
||||||
|
@ -103,6 +121,11 @@ GitVisuals.prototype.animateAll = function(speed) {
|
||||||
this.animateRefs(speed);
|
this.animateRefs(speed);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitVisuals.prototype.fullCalc = function() {
|
||||||
|
this.calcTreeCoords();
|
||||||
|
this.calcGraphicsCoords();
|
||||||
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.calcTreeCoords = function() {
|
GitVisuals.prototype.calcTreeCoords = function() {
|
||||||
// this method can only contain things that dont rely on graphics
|
// this method can only contain things that dont rely on graphics
|
||||||
if (!this.rootCommit) {
|
if (!this.rootCommit) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue