Jquery根据拖动的边缘调整插件最小宽度

时间:2012-05-27 16:57:43

标签: javascript jquery jquery-ui jquery-plugins jquery-resizable

  

可能重复:
  Jquery resizable plugin, set minWidth depending on the dragging edge

如何设置minWidth和height取决于拖动元素的哪个边缘?

1 个答案:

答案 0 :(得分:0)

有点奇怪的互动,但这里是(jsfiddle

$(function() {
    $( "#resizable" ).resizable({
        handles : 'e, n, s, w',
        resize : function(event, ui){
            switch($(this).data('resizable').axis)
            {
                case 'n':
                    $(this).resizable( "option", "minHeight", 75 );
                    break;
                case 's':
                    $(this).resizable( "option", "minHeight", 100 );
                    break;
                case 'e':
                    $(this).resizable( "option", "minWidth", 150 );
                    break;
                case 'w':
                    $(this).resizable( "option", "minWidth", 200 );
                    break;
            }
        }
    });
});​