Search code examples
jqueryjquery-uijquery-ui-resizable

jQuery resizable - how to check direction on start event


I initialize resizable DIV as

$('#someDiv').resizable({
    handles: "n, e, s, w",
    start: function(event, ui) {
        //    figure out the resize direction here...
    }
});

How I can know the direction at the start of a resize operation?

Here is the fiddle


Solution

  • JS:

    $('#someDiv').resizable({
        handles: "n, e, s, w",
        start: function (event, ui) {
            //    figure out the resize direction here...
            console.log(event);
            var srcEl = event.originalEvent.srcElement.className;
            console.log(srcEl);
            var direction = srcEl.replace('ui-resizable-handle ui-resizable-', '');
            console.log(srcEl, direction);
            console.log('You are manipulating', direction);
        }
    });
    

    Demo:http://jsfiddle.net/robschmuecker/gwztt6ur/1/