对于其他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!
}
});
答案 0 :(得分:0)