Skip to content Skip to sidebar Skip to footer

Animating Frame Resizing

Is it possible to animate the re-sizing of a frame in html? I have a webpage where there a are two frames horizontally stacked (say 500px, remaining). Upon click of a 'minimize' im

Solution 1:

If you are seeking to animate inner frames then I would go with Dr Molle's answer. If, however you are seeking to animate a frameset, you will have to do it manually. The example below illustrates. To examine it, you 'd better use a local web server to avoid problems with cross - domain restrictions (at least in Chrome, haven't tested it anywhere else...).

frame1.html

<html><body>
        frame 1
        <br /><ahref='#'class='minimize'>Minimize</a><scripttype="text/javascript"src="http://code.jquery.com/jquery-latest.min.js"></script><scripttype='text/javascript'>
            $(function () { 
                $('.minimize').click(function (evt) {
                    evt.preventDefault();
                    window.parent.minimize();
                    returnfalse;
                });
            });
        </script></body></html>

frame2.html

<html><body>frame 2</body></html>

frameset.html

<html><head><scripttype="text/javascript"src="http://code.jquery.com/jquery-latest.min.js"></script><scripttype='text/javascript'>
            $(function () { 
                var minimizeInterval = null;
                var current = 500;
                var pace = 15;
                var stop = 100;

                window.minimize = function () {
                    minimizeInterval = setInterval(function () {
                    console.log('minimizing...');
                        $('frameset').attr('cols', current + ',*');
                        current -= pace;
                        if (current < stop) 
                            clearInterval(minimizeInterval);
                    }, 10);
                };
            });
        </script></head><framesetcols="500,*"><frameid='frame1'src="frame1.html"></frame><frameid='frame2'src="frame2.html"></frame></frameset></html>

Solution 2:

Use jQuery's animate:

$('#frameselector').animate({width:100});

Solution 3:

Yes, you can animate most css properties.

Here's a sample : when you click on the left frame the right one is animated and reduces in size.

This is done using :

$('#a').click(function(){
    $('#b').animate({
        height: '50px'
    }, 5000);
});​

Post a Comment for "Animating Frame Resizing"