mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +02:00
45 lines
970 B
JavaScript
45 lines
970 B
JavaScript
var _ = require('underscore');
|
|
var Backbone = require('backbone');
|
|
|
|
var VisBase = Backbone.Model.extend({
|
|
removeKeys: function(keys) {
|
|
_.each(keys, function(key) {
|
|
if (this.get(key)) {
|
|
this.get(key).remove();
|
|
}
|
|
}, this);
|
|
},
|
|
|
|
animateAttrKeys: function(keys, attrObj, speed, easing) {
|
|
// either we animate a specific subset of keys or all
|
|
// possible things we could animate
|
|
keys = Object.assign(
|
|
{},
|
|
{
|
|
include: ['circle', 'arrow', 'rect', 'path', 'text'],
|
|
exclude: []
|
|
},
|
|
keys || {}
|
|
);
|
|
|
|
var attr = this.getAttributes();
|
|
|
|
// safely insert this attribute into all the keys we want
|
|
_.each(keys.include, function(key) {
|
|
attr[key] = Object.assign(
|
|
{},
|
|
attr[key],
|
|
attrObj
|
|
);
|
|
});
|
|
|
|
_.each(keys.exclude, function(key) {
|
|
delete attr[key];
|
|
});
|
|
|
|
this.animateToAttr(attr, speed, easing);
|
|
}
|
|
});
|
|
|
|
exports.VisBase = VisBase;
|
|
|