Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expand An Iframe During jQuery Animation When Contents Expand

I'm working on a user dashboard project where a user can interact with widgets (very similar to iGoogle dashboard). I'm using jQueryUI portlets to hold iframes. The problem I'm running into is that I would like to resize the iframe in real-time when the contents inside the iframe expand using jQuery animation. For example, I have a custom accordion control inside an iframe. When the user clicks on a panel to expand the accordion, I call the slideDown() function to show the content. When the slideDown() animation is complete, I resize the iframe based on the body's new height. The result is the contents of the accordion slide down until they go out of bounds of the widget during the slide animation. Once the animation is complete, the resize takes care of the new widget height and everything looks good. This is pretty choppy animation and I would like to resize the iframe so it expands to the iframe's body height during the slideDown() animation. What can I do to expand the iframe based on the body height during the slide animation?

Here is the code I'm currently using.

// This code gets fired on an accordion panel click event.
content.slideDown(100, function ()
{
    parent.expandContainer('panel1', $('body').height());
});     

// This code resides in the parent page hosting the iframes.
function expandContainer(elementId, height)
{
    $('#' + elementId).children('.content').find('iframe').css('height', height + 'px');
}   
like image 578
Halcyon Avatar asked Dec 04 '25 15:12

Halcyon


1 Answers

it is possible, you have to make your one accordion to get the step-event of the performed animation.

i've created a animated box. if the box is getting bigger or smaller, the step-event calls the function resizeIframe(height). this function again call the homonymous function resizeIframe(height) in the parent document. try this demo:

http://algorhythm.de/tools/resizeable-iframe/index.html

like image 101
algorhythm Avatar answered Dec 07 '25 03:12

algorhythm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!