[Origin] Makes two visualizations now and links the objects and small graphical updates

This commit is contained in:
Peter Cottle 2013-05-26 16:34:54 -07:00
parent 5e151238c9
commit 91f0e13132
5 changed files with 180 additions and 99 deletions

View file

@ -10,6 +10,50 @@ var VisBase = Backbone.Model.extend({
}, this);
},
getNonAnimateKeys: function() {
return [
'stroke-dasharray'
];
},
getIsInOrigin: function() {
if (!this.get('gitEngine')) {
return false;
}
return this.get('gitEngine').isOrigin();
},
animateToAttr: function(attr, speed, easing) {
if (speed === 0) {
this.setAttr(attr, /* instant */ true);
return;
}
var s = speed !== undefined ? speed : this.get('animationSpeed');
var e = easing || this.get('animationEasing');
this.setAttr(attr, /* instance */ false, s, e);
},
setAttrBase: function(keys, attr, instant, speed, easing) {
_.each(keys, function(key) {
if (instant) {
this.get(key).attr(attr[key]);
} else {
this.get(key).stop().animate(attr[key], speed, easing);
// some keys dont support animating too, so set those instantly here
_.forEach(this.getNonAnimateKeys(), function(nonAnimateKey) {
if (attr[key] && attr[key][nonAnimateKey] !== undefined) {
this.get(key).attr(nonAnimateKey, attr[key][nonAnimateKey]);
}
}, this);
}
if (attr.css) {
$(this.get(key).node).css(attr.css);
}
}, this);
},
animateAttrKeys: function(keys, attrObj, speed, easing) {
// either we animate a specific subset of keys or all
// possible things we could animate