I find that I need these four pieces of code. If I adjust a token to a size other than 1x1 unit, the width can become 140.00000000000001, or the left might be 804.999999999999 or the like.
on("change:token:left", function(obj, prev) {
// Clean up fractional pixels
var oldValue = obj.get("left");
var newValue = Math.round(oldValue);
obj.set("left", newValue);
log("change:left "+oldValue+", "+newValue+", "+obj.get("left"));
});
on("change:token:top", function(obj, prev) {
// Clean up fractional pixels
var oldValue = obj.get("top");
var newValue = Math.round(oldValue);
obj.set("top", newValue);
log("change:top "+oldValue+", "+newValue+", "+obj.get("top"));
});
on("change:token:width", function(obj, prev) {
// Clean up fractional pixels
var oldValue = obj.get("width");
var newValue = Math.round(oldValue);
obj.set("width", newValue);
log("change:width "+oldValue+", "+newValue+", "+obj.get("width"));
});
on("change:token:height", function(obj, prev) {
// Clean up fractional pixels
var oldValue = obj.get("height");
var newValue = Math.round(oldValue);
obj.set("height", newValue);
log("change:height "+oldValue+", "+newValue+", "+obj.get("height"));
});