Search code examples
mootoolsmootools-fx

setting mootools fx.morph height to auto instead of a fix height


I'm trying to show my nav using fx.morph the code is as below:

 var fx = new Fx.Morph(_element, { 
     duration: 1000,transition:Fx.Transitions.Sine.easeOut
                                 });
 fx.start({
          'height': [0, 100]
           });
 }

it works well,the thing that i need is to set height from 0 to auto instead of 0 to 100.is there any solution to do that?I try auto and 100% but it didn't work.


Solution

  • I've done it myself.I just add a container and after that calculat the height of that container and us it as the height.

        var _element = el.getElement('.child_first_nav_mobile');
                if (_element) {
    
                    var fx = new Fx.Morph(_element, { duration: 1000 });
                    var autoheightdiv = _element;
                    autoheightdiv.style.height='auto';
                    var calcheight=autoheightdiv.offsetHeight
                    fx.start({
                        'height': [0, calcheight] 
                        });