1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Fix animation behaviour of reveal widget

This commit is contained in:
Jeremy Ruston 2013-11-02 09:21:11 +00:00
parent 73ca33d82d
commit 31ae8910c6
2 changed files with 12 additions and 5 deletions

View File

@ -89,6 +89,8 @@ RevealWidget.prototype.execute = function() {
this["default"] = this.getAttribute("default","");
this.qualifyTiddlerTitles = this.getAttribute("qualifyTiddlerTitles");
this.animate = this.getAttribute("animate","no");
this.openAnimation = this.animate === "no" ? undefined : "open";
this.closeAnimation = this.animate === "no" ? undefined : "close";
// Compute the title of the state tiddler and read it
this.stateTitle = this.state;
if(this.qualifyTiddlerTitles) {
@ -184,9 +186,9 @@ RevealWidget.prototype.updateState = function() {
}
if(this.isOpen) {
domNode.removeAttribute("hidden");
$tw.anim.perform("open",domNode);
$tw.anim.perform(this.openAnimation,domNode);
} else {
$tw.anim.perform("close",domNode,{callback: function() {
$tw.anim.perform(this.closeAnimation,domNode,{callback: function() {
domNode.setAttribute("hidden","true");
}});
}

View File

@ -27,10 +27,15 @@ Animator.prototype.perform = function(type,domNode,options) {
chosenAnimation = animation[type];
}
});
// Call the animation
if(chosenAnimation) {
chosenAnimation(domNode,options);
if(!chosenAnimation) {
chosenAnimation = function(domNode,options) {
if(options.callback) {
options.callback();
}
};
}
// Call the animation
chosenAnimation(domNode,options);
};
exports.Animator = Animator;