1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-29 00:33:15 +00:00
TiddlyWiki5/core/modules/utils/dom/animator.js
2013-11-02 09:21:11 +00:00

44 lines
913 B
JavaScript

/*\
title: $:/core/modules/utils/dom/animator.js
type: application/javascript
module-type: utils
Orchestrates animations and transitions
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
function Animator() {
// Get the registered animation modules
this.animations = {};
$tw.modules.applyMethods("animation",this.animations);
}
Animator.prototype.perform = function(type,domNode,options) {
options = options || {};
// Find an animation that can handle this type
var chosenAnimation;
$tw.utils.each(this.animations,function(animation,name) {
if($tw.utils.hop(animation,type)) {
chosenAnimation = animation[type];
}
});
if(!chosenAnimation) {
chosenAnimation = function(domNode,options) {
if(options.callback) {
options.callback();
}
};
}
// Call the animation
chosenAnimation(domNode,options);
};
exports.Animator = Animator;
})();