Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know which handle is getting used in jquery resizable

i am using jquery resizable to resize a div

$("#mainDiv").resizable({
        handles: 's, e',
        start: function(event, ui) { 
        // want to perform some action here
    },
        resize: function(event, ui) { 
        // want to perform some action here }
    });

now i want to do some stuff based on fact that whether s or e is selected to resize basically resizing is vertical or horizontal how to do that

Thanks

like image 794
Varun Avatar asked Aug 19 '11 08:08

Varun


2 Answers

The axis is placed as data on your element under ui-resizable like this:

$(element).data('ui-resizable').axis

like image 120
user3322509 Avatar answered Nov 14 '22 21:11

user3322509


// the following will return direction as "n", "e", "s", "se" etc.
$("#selector").resizable({
    resize: function(e, ui) {
        // for jquery-ui 1.9.2
        var direction = $(this).data('resizable').axis;
        // for jquery-ui 1.11.4
        var direction = $(this).data('ui-resizable').axis;
    }
});
like image 44
Arsen K. Avatar answered Nov 14 '22 22:11

Arsen K.