1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-05 11:43:16 +00:00
TiddlyWiki5/core/modules/utils/dom/animator.js
Jeremy Ruston 227cadd326 Add a barebones animation framework
The idea is to allow us to package animations/transitions into plugins
2013-05-28 16:28:16 +01:00

39 lines
805 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];
}
});
// Call the animation
if(chosenAnimation) {
chosenAnimation(domNode,options);
}
};
exports.Animator = Animator;
})();