Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
673 views
in Technique[技术] by (71.8m points)

html - 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');
}   
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...