Michael Michael - 13 days ago 8
Javascript Question

How to get X Y coordinates in resizable function?

I use resize method on jquery-ui, here is my function:

$( function() {
$( "#resizable" ).resizable();
startResizing(event.clientX,event.clientX)//how to get coordinates
});


And here my resizable div:

<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Resizable</h3>
</div>


In the function above when div resizable is resized I need to call function named
startResizing()
and pass X,Y coordinates.

My question is how can I get X,Y coordinates call
startResizing()
function each time when div have been resized?

Answer

You can use the resize event of the resizable method:

$(function() {
    $("#resizable").resizable({
        resize: function(e, ui) {
            startResizing(ui.position.left, ui.position.right);
        }
    });
});

More info available in the jQuery UI documentation: http://api.jqueryui.com/resizable/#event-resize

Comments