jQuery可调整大小 - 如何检查启动事件的方向

时间:2014-08-06 21:08:26

标签: jquery jquery-ui jquery-ui-resizable

我将可调整大小的DIV初始化为

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

如何知道调整大小操作开始时的方向?

以下是fiddle

1 个答案:

答案 0 :(得分:-2)

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);
    }
});

演示:http://jsfiddle.net/robschmuecker/gwztt6ur/1/