From 31ae8910c615a1bb1303c885e9fd03a617c79d5e Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 2 Nov 2013 09:21:11 +0000 Subject: [PATCH] Fix animation behaviour of reveal widget --- core/modules/new_widgets/reveal.js | 6 ++++-- core/modules/utils/dom/animator.js | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/modules/new_widgets/reveal.js b/core/modules/new_widgets/reveal.js index 8d82b2ae0..5cdc06e0a 100755 --- a/core/modules/new_widgets/reveal.js +++ b/core/modules/new_widgets/reveal.js @@ -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"); }}); } diff --git a/core/modules/utils/dom/animator.js b/core/modules/utils/dom/animator.js index 50d31b795..f994d9b58 100644 --- a/core/modules/utils/dom/animator.js +++ b/core/modules/utils/dom/animator.js @@ -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;