Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery UI resizable does not support position: fixed; Any recommendations?

JQuery UI's .resizable function does not support position: fixed; elements. The moment you try to resize them it switches their position attribute to absolute. Any recommended fixes?

I have some chat windows that pop up and are draggable around the document. They are position fixed so that they don't scroll with the page behind them. They all work perfectly until you try to resize a window, that's when it transitions to position: absolute; and then gets left behind when the page scrolls.

I tried handling the resize stop event and changing the position to fixed:

    stop: function (event, ui)
    {
        $(chatWindow).css('position', 'fixed');
    }

This doesn't work because the positioning (top: and left:) are not correct for the fixed element and when you stop resizing the element switches to fixed positioning and jumps to weird places on the page. Sometimes jumps out of the page boundries and is lost forever.

Any suggestions?

like image 458
Chev Avatar asked Jan 27 '11 17:01

Chev


1 Answers

To get over this problem I wrapped the .resizable() block with the .draggable() block:

<div id="draggable-dealie">
    <div id="resizable-dealie">
    </div>
</div>

the corresponding js:

$("#draggable-dealie").draggable();
$("#resizable-dealie").resizable();

and ensure you have the property position:fixed !important; set in the #draggable-dealie CSS:

#draggable-dealie {
    position:fixed !important;
    width:auto;
    height:auto;
}

I have a demonstration at: http://jsfiddle.net/smokinjoe/FfRRW/8/

like image 134
Smokin Joe Avatar answered Sep 23 '22 07:09

Smokin Joe