Making interact.js resizable pixel perfect
问题 In this jsFiddle I have an SVG rect that is resizable using interact.js . There's also a 10px by 10px grid and the .resizable function has included a 10px by 10 px snap. The objective is to resize the rect and have the edges snap exactly on the grid. In most cases it works fine, but many times it is not, as you can see in the picture below. Maybe an adjustment needs to be done manually on resizeend ? How to fix this problem? 回答1: As Erik said: With this target.setAttribute(attr/a, Math.round