resize - Javascript elements only snapping to grid from right side -
i trying resize elements snap grid , far working if resize right side , bottom reason doesn't work left side. sure it's math here code:
var dimension = win.getdimension(); var neww = math.round(dimension[0] / 10) * 10; var newh = math.round(dimension[1] / 10) * 10; win.setdimension(neww, newh);
any ideas?
so ended doing having event called onbeforeresizestart saved current x position window , in onresizefinish event checked see if new x position matched saved x position. if did not updated x position , did same snap calculation.
onbeforeresizestart:
var position = getcoords(win); window.currentx = position.left;
onresizefinish
var position = getcoords(win); if(position.left != window.currentx) { var newx = math.round(position.left / 10) * 10; win.setposition(newx, position.top); } var dimension = win.getdimension(); var neww = math.round(dimension[0] / 10) * 10; var newh = math.round(dimension[1] / 10) * 10; win.setdimension(neww, newh);
Comments
Post a Comment