PDA

View Full Version : wrong effect when hiding an animated, modal, BasicDialog



gcsolaroli
20 Nov 2006, 2:54 PM
I am making some progress using YUI-ext and I have managed to set up a modal, animated, BasicDialog.

Everything works fine, but I found the exit animation (the one invoked by the 'hide') method to be somehow wrong, as the "modal shadow" (the shadow that cover the whole window) is removed before starting the hiding animation.

I think that, to be coherent, the "modal shadow" should be removed last, as the modal status is removed only after the dialog is closed.

At the moment I have been able to achieve this behaviour with the following patch.

===================================================================
--- widgets/BasicDialog.js (revision 4)
+++ widgets/BasicDialog.js (working copy)
@@ -535,10 +535,12 @@

beforeHide : function(){
YAHOO.util.Event.removeListener(document, 'keydown', this.keyDownDelegate);
- if(this.modal){
- this.mask.hide();
- YAHOO.util.Dom.removeClass(document.body, 'masked');
- }
+ if(!this.animateTarget){
+ if(this.modal){
+ this.mask.hide();
+ YAHOO.util.Dom.removeClass(document.body, 'masked');
+ }
+ }
},

/**
@@ -571,6 +573,12 @@
hideEl : function(callback){
this.proxy.hide();
this.fireEvent('hide', this);
+
+ if(this.modal){
+ this.mask.hide();
+ YAHOO.util.Dom.removeClass(document.body, 'masked');
+ }
+
if(typeof callback == 'function'){
callback();
}


I am using only BasicDialog at the moment, so I don't know if this patch breaks something else on the library. It is also possible that this is not the best way to achieve the desired outcome.

Hope this helps.

jack.slocum
21 Nov 2006, 3:56 AM
With that in place if there is no animation they the modal mask never hides. :shock:

My initial thought was the modal mask should be removed before the animation - so the user doesn't have to wait for it. However, this is inconsistent with the show behavior so I changed it as you have suggested.

gcsolaroli
21 Nov 2006, 6:51 AM
Jack,

if I am not completely wrong, when there is no animation, the mask should be removed in the beforeHide method, just like before.

Instead, if there is an animation in place, the mask is removed in the hideEl callback performed after the hide animation.

At least this is what I was trying to achieve.

jack.slocum
21 Nov 2006, 7:06 AM
Ah I see. You just have an old version of the code. ;)