2013-05-28 15:28:16 +00:00
|
|
|
/*\
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
});
|
2013-11-02 09:21:11 +00:00
|
|
|
if(!chosenAnimation) {
|
|
|
|
chosenAnimation = function(domNode,options) {
|
|
|
|
if(options.callback) {
|
|
|
|
options.callback();
|
|
|
|
}
|
|
|
|
};
|
2013-05-28 15:28:16 +00:00
|
|
|
}
|
2013-11-02 09:21:11 +00:00
|
|
|
// Call the animation
|
|
|
|
chosenAnimation(domNode,options);
|
2013-05-28 15:28:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.Animator = Animator;
|
|
|
|
|
|
|
|
})();
|