jqueryUI Resizable的步长值?

时间:2014-07-19 06:40:45

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

对于其他jquery交互/小部件,有步骤值。

我如何强制调整大小以增加/减少某些值?

我必须做这样的事吗? (侧面问题,为了更有效的黑客攻击,我怎么知道哪个罗盘点正在调整大小?)

var desiredStepPixels = 8;
var containmentLeftPos = 100;
var containmentTopPos = 250;

$("#resizeDivID").resizable({
    resize: function( event, ui ) {
       var newLeftPxValue = $("#resizeDivID").css("left");
       var leftPxModulus = (newLeftPxValue - containmentLeftPos ) % desiredStepPixels;
       if ( leftPxModulus != 0){
            if (leftPxModulus>(desiredStepPixels/2)){
                var forcedNewLeftPx = newLeftPxValue + (desiredStepPixels - leftPxModulus);
                $("#resizeDivID").css({"left":forcedNewLeftPx});    
            }else{
                //force a round down on the left side
            }
       }
       //and then etc etc for top, width and height!
    }
});

1 个答案:

答案 0 :(得分:0)

我的坏,道歉。当然Jquery已经想到了这个!

称为GRID http://api.jqueryui.com/resizable/#option-grid

我道歉,我检查了文档,但没看到我在找什么!