mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 00:18:56 +02:00
have somewhat ok global lock on animation down, better than nothing
This commit is contained in:
parent
ef5ff59cca
commit
a9e4d5a9a6
5 changed files with 18 additions and 103 deletions
|
@ -43,10 +43,15 @@ var AnimationQueue = Backbone.Model.extend({
|
|||
|
||||
start: function() {
|
||||
this.set('index', 0);
|
||||
|
||||
// set the global lock that we are animating
|
||||
GLOBAL.isAnimating = true;
|
||||
this.next();
|
||||
},
|
||||
|
||||
finish: function() {
|
||||
// release lock here
|
||||
GLOBAL.isAnimating = false;
|
||||
this.get('callback')();
|
||||
},
|
||||
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
|
||||
/**
|
||||
* Constants....!!!
|
||||
*/
|
||||
var constants = {
|
||||
clickDragMass: 20,
|
||||
baseMass: 1,
|
||||
};
|
||||
|
||||
var TIME = {
|
||||
betweenCommandsDelay: 400,
|
||||
commandShow: 300,
|
||||
reflowGuess: 100
|
||||
};
|
||||
|
||||
// useful for locks, etc
|
||||
var GLOBAL = {
|
||||
isAnimating: false
|
||||
};
|
||||
|
||||
var GRAPHICS = {
|
||||
|
@ -43,39 +40,3 @@ var GRAPHICS = {
|
|||
orphanNodeFill: 'hsb(0.5,0.8,0.7)',
|
||||
};
|
||||
|
||||
/**
|
||||
* Graphics style -- DEPRECATED
|
||||
*/
|
||||
var graphics = {
|
||||
// colors
|
||||
edgeStroke: 'rgba(94%, 96%, 98%, 0.5)', // '#EFF5FB',
|
||||
nodeEdge: 'rgba(94%, 96%, 98%, 0.9)', // '#EFF5FB',
|
||||
nodeFill: '#0066cc',
|
||||
nodeRadius: 10,
|
||||
|
||||
// widths
|
||||
nodeStrokeWidth: 15,
|
||||
edgeWidth: 2,
|
||||
|
||||
// ref names
|
||||
refFont: '14pt Courier New',
|
||||
refFontFill: '#FFF',
|
||||
refSelectedFontFill: 'rgb(255, 30, 10)',
|
||||
|
||||
// ref arrows
|
||||
arrowFill: '#FFF',
|
||||
arrowStroke: '#000',
|
||||
arrowWidth: 4,
|
||||
arrowHeadWidth: 5,
|
||||
};
|
||||
|
||||
function randomString(string_length) {
|
||||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
||||
var randomstring = '';
|
||||
for (var i=0; i<string_length; i++) {
|
||||
var rnum = Math.floor(Math.random() * chars.length);
|
||||
randomstring += chars.substring(rnum,rnum+1);
|
||||
}
|
||||
return randomstring;
|
||||
}
|
||||
|
||||
|
|
51
src/git.js
51
src/git.js
|
@ -568,57 +568,6 @@ GitEngine.prototype.rebaseStarter = function() {
|
|||
animationFactory.rebaseAnimation(this.animationQueue, response, this);
|
||||
};
|
||||
|
||||
GitEngine.prototype.rebaseAnimation = function(response) {
|
||||
/*
|
||||
// TODO: move to animation factory
|
||||
var start = function() {
|
||||
// maybe search stuff??
|
||||
};
|
||||
|
||||
this.animationQueue.add(new Animation({
|
||||
closure: start
|
||||
}));
|
||||
|
||||
// first set all birth positions...
|
||||
_.each(response, function(step) {
|
||||
step.newCommit.get('visNode').setBirth();
|
||||
}, this);
|
||||
|
||||
var fixedOpacity = 0.8;
|
||||
// then fix all opacities... ugh
|
||||
_.each(response, function(step) {
|
||||
_.each(step.snapshot, function(obj) {
|
||||
_.each(obj, function(attr) {
|
||||
if (attr.opacity !== undefined) {
|
||||
attr.opacity = fixedOpacity;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var time = GRAPHICS.defaultAnimationTime;
|
||||
var bounceTime = time * 2.0;
|
||||
|
||||
_.each(response, function(step) {
|
||||
this.animationQueue.add(new Animation({
|
||||
closure: function() {
|
||||
var id = step.newCommit.get('id');
|
||||
var vNode = step.newCommit.get('visNode');
|
||||
|
||||
vNode.setBirth();
|
||||
vNode.setOutgoingEdgesBirthPosition();
|
||||
|
||||
vNode.animateOutgoingEdgesFromSnapshot(step.snapshot, bounceTime, 'bounce');
|
||||
vNode.animateFromAttr(step.snapshot[id], bounceTime, 'bounce');
|
||||
},
|
||||
duration: Math.max(bounceTime, time)
|
||||
}));
|
||||
}, this);
|
||||
|
||||
animationFactory.refreshTree(this.animationQueue);
|
||||
*/
|
||||
};
|
||||
|
||||
GitEngine.prototype.rebase = function(targetSource, currentLocation) {
|
||||
// first some conditions
|
||||
if (this.isUpstreamOf(targetSource, currentLocation)) {
|
||||
|
|
|
@ -392,8 +392,11 @@ GitVisuals.prototype.canvasResize = function(width, height) {
|
|||
this.paperHeight = height;
|
||||
|
||||
// refresh when we are ready
|
||||
this.refreshTree();
|
||||
// TODO when animation is happening, do this: events.trigger('processCommandFromEvent', 'refresh');
|
||||
if (GLOBAL.isAnimating) {
|
||||
events.trigger('processCommandFromEvent', 'refresh');
|
||||
} else {
|
||||
this.refreshTree();
|
||||
}
|
||||
};
|
||||
|
||||
GitVisuals.prototype.addNode = function(id, commit) {
|
||||
|
|
9
todo.txt
9
todo.txt
|
@ -1,10 +1,7 @@
|
|||
closures on animations with those snapshots
|
||||
integrate animation into all git commands
|
||||
Big things:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
- Interactive rebasing :OOOO
|
||||
|
||||
animation factory? stuff like:
|
||||
|
||||
-highlightCommit(50, 'targetColor') // during search
|
||||
-clearHighlightsAllNodes
|
||||
|
||||
Big Graphic things:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue