Monday, 15 July 2013

Mootools Morph Height and back -



Mootools Morph Height and back -

im looking solution for: want toggel height of div not complet. seek didnt work. see first classchange in firebug , heigth alter 36px. didnt work. seek wiht add together , remove class.

http://jsfiddle.net/zbbd9/1/

$$('.outer').setstyle('height', '660px'); $$('.outer h2').addevent('click', function(){ if (this.hasclass('close')) { var parent = this.getparent(); parent.removeclass('close'); parent.morph({ 'height': '660px' }); } else { var parent = this.getparent(); parent.addclass('close'); parent.morph({ 'height': '36px' }); } });

update:

http://jsfiddle.net/zbbd9/2/

got it.

best regards

you're selecting wrong parent container.

try this:

$$('.outer h2').addevent('click', function(){ var parent = this.getparent(); if (parent.hasclass('close')) { parent.removeclass('close'); parent.morph({ 'height': '660px' }); } else { parent.addclass('close'); parent.morph({ 'height': '36px' }); } });

adding class identify current state solid way it, might want consider other alternatives, too, using toggleclass or referring different slider or similar.

height mootools toggle

No comments:

Post a Comment